How foreign key can reduce redundancy in the database design

Showing Answers 1 - 12 of 12 Answers

Jigar Khatri

  • 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)

  Was this answer useful?  Yes

raji_4u

  • Sep 19th, 2008
 

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


  Was this answer useful?  Yes

malapati

  • Oct 10th, 2008
 

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".

  Was this answer useful?  Yes

skcwebworld

  • Aug 26th, 2015
 

Since Foreign key accepts null values, then if we inset a record as NULL then how we can make Customer id as primary key in another table.

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions