Re: Number of foreign keys
Date: 2 Dec 2004 03:20:07 -0800
Message-ID: <1101986407.019023.204010_at_f14g2000cwb.googlegroups.com>
Vinodh Kumar P wrote:
> I understand the number of foreign keys allowed is restricted by the
DBMS I
> use.
> In a general relational schema design perspective how many foreign
keys a
> table shall have?
Precisely as many as it requires - no more, no less. If that is more
than your DBMS allows then you have an issue.
> If I have large number of foreign keys what anamolies it will lead
to?
None. It is the LACK of required foreign keys that will lead to
anomalies.
> Is this crucial to identify all the foriegn key relationships for a
table?
Yes
Having said all that, if you find yourself designing a table that needs 100s of foreign keys, many of them referencing the same parent table, then it is quite likely that your design isn't good. For example this is a bad design:
CREATE TABLE department
( deptno INT PRIMARY KEY
, empno1 REREFENCES employee , empno2 REREFENCES employee , empno3 REREFENCES employee , empno4 REREFENCES employee , empno5 REREFENCES employee , empno6 REREFENCES employee , empno7 REREFENCES employee , empno8 REREFENCES employee , empno9 REREFENCES employee
...
); Received on Thu Dec 02 2004 - 12:20:07 CET