database structure
I have a table A with a composite primary key and I have table B where I need to have Table A's colum(s) as foreign key. Do I need to add both column's of Table A in Table B as foreign key?
开发者_开发知识库Please suggest.
Yes you have to add all the columns from table A that defines the primary key to table B.
Create a surrogate in table A to use as the primary key, and use the composite key columns as a superkey (create a unique, non-null index on the columns). Have the foreign key in table B refer to the surrogate column.
Yes you can add both column of table A in table B and can make only One column of table A as foreign Key in table B and also can make both column of table A as foeign key in table B.
精彩评论