Foreign Key to Primary key relation

rgx71

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?

Heinzi

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it possible to have a relation where the foreign key is also the primary key?

From Dev

PrImary key or foreign key for a m-to-n relation table

From Dev

foreign key is not equal to primary key

From Dev

Find foreign key by primary key?

From Dev

Replacing a foreign key by a primary key

From Dev

Insert 2 rows in tables with foreign key relation without knowing the primary key of the main table

From Dev

Yii relation — MySQL foreign key

From Dev

Use foreign keys as primary key

From Dev

Foreign and Primary Key Conceptual Questions

From Dev

Primary & Foreign Key Constraints Confusion

From Dev

Hibernate Primary Foreign Key field

From Dev

create primary and foreign key relationship

From Dev

Two foreign keys as primary key

From Dev

A foreign key can be primary in sql

From Dev

Hibernate Primary Foreign Key field

From Dev

Finding Primary Table for a Foreign Key

From Dev

Use of Primary Key as Foreign Key in Foreign Key Table

From Java

Foreign Key to non-primary key

From Dev

Delete foreign key with primary key reference

From Dev

Hibernate foreign key with a part of composite primary key

From Dev

Can a foreign key act as a primary key?

From Dev

Clustered index on foreign key or primary key?

From Dev

Can a foreign key be the only primary key

From Dev

Mapping of primary key as foreign key to another table

From Dev

Foreign Key not reference to Primary Key in MySQL (phpMyAdmin)

From Dev

Belongs_to association with primary key and foreign key

From Dev

Foreign key in MySql as composite primary key

From Dev

2 foreign key references for a single primary key

From Dev

Using a foreign key as part of a composite primary key

Related Related

HotTag

Archive