I saw a table that has a PK of type int and then a FK that is pointed from the same column to the same column.
For example
Table1
ID int identity
Name nvarchar(50)
ID is the primary key. When I try to see the relations, I see a foreign key from Table1.ID to Table1ID, what does it means?
If that is really a FK from the same field to the same field, it does not make much sense.
However, in general, a FK that references its own table can be useful. Consider the following employee table, for example:
ID int identity
Name nvarchar(50)
SupervisorID int nullable -> FK to ID
SupervisorID can point to another employee and create a hierarchy.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments