Re: Number of foreign keys
Date: 2 Dec 2004 03:20:07 -0800
Vinodh Kumar P wrote:
> I understand the number of foreign keys allowed is restricted by the
> In a general relational schema design perspective how many foreign
> 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
None. It is the LACK of required foreign keys that will lead to anomalies.
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