Re: Referrential Integrity Question
Posted in 1995
In article <3t1l0c$7n3@cssun.mathcs.emory.edu>, jvemo@cyberspace.com (Jon C. Vemo) says: > >What is the best approach to insure referrential integrity at the server, >between two tables when: > - The parent table (tab1) has a primary key on (col1,col2), and contains > many rows with duplicates in col1 > - The child table (tab2) contains (col1) values with a contraint >before an > insert or update (i.e. tab2.col1 values must exist in tab1.col1) Ignoring issues such as what is the logic behind the database structure, the only way I can see this working is to create a 3rd table tab3 with a primary key of col1 Then declare col1 in both tab1 and tab2 as a foreign key referencing tab3.col1 You can still have a primary key of col1,col2 on tab1 The only thing is that before you insert into tab1, the relevant value must exist in tab3.col1