GeekInterview.com
Series: Subject: Topic:
Question: 80 of 214

How foreign key can reduce redundancy in the database design

Asked by: Interview Candidate | Asked on: Mar 26th, 2007
Showing Answers 1 - 3 of 3 Answers
Jigar Khatri

Answered On : Mar 28th, 2007

Hi,

Answer is :

Foreign Key can not reduce redundacy in DB as it supports duplicate as well as NULL values.

But it is very useful to maintain the Referencial Integrity (Foreign Key Constrints) in DB.

Thank you. (If you have any different asnwers please post it)

  
Login to rate this answer.
raji_4u

Answered On : Sep 19th, 2008

View all answers by raji_4u

i think it can reduce reduncency.

suppose we have a table

table :orders
--------------------------
customer_id       order_no      customer_address
---------------------------------------------------------------
1                       O11               US
2                       O22               UK
3                       O33               IND
1                       O44               US      --> duplicate
3                       O55               IND    --> duplicate
------------------------------------------------------------------
here customers 1,3 made two orders. so the customer_address is duplicated for each order.

we can resolve this by foreign key integrity.

table : orders
-----------------------------------------
customer_id      order_no         |          here customer_id is FOREIGN KEY
-----------------------------------------
1                      O11
2                      O22
3                      O33
1                      O44
3                      O55
--------------------------------------------

table : address
----------------------------------------
customer_id        address        |         Here customer_id is PRIMARY KEY
---------------------------------------
1                         US
2                         UK
3                         IND
------------------------------------------

now we can select as

select
       o.customer_id,
       o.order_no,
       a.address
from
       orders o,
       address a
where
       o.customer_id = a.customer_id


  
Login to rate this answer.
malapati

Answered On : Oct 10th, 2008

View all answers by malapati

A column included in the definition of referential integrity which would refer to a referenced key.
Referenced key is a primary key which is combination of UNIQUE+NOT NULL".

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.