This is a fairly simple question (or at least from the outset it should be).
I am looking into efficient ways to model a One to Many relationship where the many is the same type.
Example
Say we have a Person Entity, and this person has 0 to many Sub-Persons, and the Sub-Persons have 0 or 1 Parent-Person.
The answer should take into consideration read optimization & querying simplicity from Linq to Entity Framework. Answers relating to underlying Database table structure for best read performance are also very welcome (as long as they can be mapped to by EF4).
This looks like a case of self-referential foreign key. (oracle)
A generally used example is the Employee-Manager relationship.
A given employee can be a manager (to other employees) and can in-turn have a manager (or not, if he is the boss).
The table definition and constraint definition would be like this.
and the constraint would be ..
This indicates that the manager Id for a given employee must himself be an employee.
Here is the sample data.
As you can see, all employees have a manager (except KING who is the company’s boss.).
each of them is in turn an employee.
Note that this is a model that is suitable and perfect for OLTP style systems. There is no redundant data and data integrity constraints are taken care of.