Click here to Skip to main content
15,884,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can a primary key of one table be a foreign key in another table more than one time. Please see the scenario below:

Table:1
id (pk)
title
referenceID (FK)
oldreferenceID (FK)
Delphi


Table:2
referenceID (PK)
referenceTitle

Here, can i use "Table:2 referenceID (PK)" as foreign key in "Table:1 referenceID (FK) & oldreferenceID (FK) ?"

Please advise. Thanks in advance.
Posted
Comments
abbaspirmoradi 27-Oct-13 7:05am    
you should do this with triggers.
adnanrazzaqq 27-Oct-13 7:06am    
can you please brief how?

Yes, it is absolutely valid, a table can reference the same primary key in several columns.
 
Share this answer
 
Comments
adnanrazzaqq 27-Oct-13 7:08am    
Hi! Phil, can you please reference any particular link/tutorial.
Yes. It's pretty normal - think of addresses for example: a company may have a Billing address and a Delivery Address. You would only store each address once, and use Foreign Key references to attach them to the single company. Each address would have a distinct Primary Key.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900