Sunday, 15 January 2012

sql - Composite primary key with foreign keys out to different tables -



sql - Composite primary key with foreign keys out to different tables -

sql 2008 r2. have 3 tables.

**person** personid int **address** addressid int address varchar **personaddress** personid int primary key references person.personid addressid int primary key references address.addressid

i have read when there composite primary key, reference should include both columns. , yet, works me. management studio not throw error , can insert rows these tables without duplicates , adhering constraints.

is practise?

the fk should/must reference key columns of referenced table. personaddress doing 2 times.

sql sql-server tsql

No comments:

Post a Comment