Project

General

Profile

[DBO] How to specify foreign key as one of the columns in a table?

Added by Plug Gulp almost 5 years ago

Hi,

I want to specify the following relation:

+====+============+===========+===========+
| Id | First Name | Last Name | Parent Id |
+----+------------+-----------+-----------+
|  0 |  John      |  Doe      |    NULL   |
+----+------------+-----------+-----------+
|  1 |  Jane      |  Doe      |    0      |
+----+------------+-----------+-----------+
|  2 |  Little    |  Doe      |    1      |
+====+============+===========+===========+

The 'Parent Id' is a foreign key that points to the 'Id' primary key of one of the rows of the table e.g. in the above table, Little Doe has parent Jane Doe, and Jane Doe has parent John Doe.

How do I specify the 'Parent Id' using DBO?

Thanks and kind regards,

~Plug