Q
Problem solve Get help with specific problems with your technologies, process and projects.

Number of columns in primary and foreign keys

Why must the number of columns in primary keys match the number in foreign keys?

Why must the number of columns in primary keys match the number in foreign keys?
I would say it is the other way around. The number of columns in the Foreign Key constraint matches the number of columns in the Primary Key. After all, the FK constraint refers to the PK constraint, not the other way around. A row in the child table needs to find a specific record in the parent table. In order to be able to guarantee that you can uniquely identify a record in any table, you need a PK constraint. Without a PK constraint, you may have duplicate records. If you have duplicate records, which row is the parent of in the child table?

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close