
Originally Posted by
DatabaseDesigner
May I suggest the use of a Unary relationship to handle your parent/child relationships?
Put simply, your table would have its usual id (primary key) and a foreign key maybe named PID or parent_id (whatever your preference. The foreign key will represent a record within the same table. Example:
ID = 1, PID = NULL, name = home
ID = 2, PID= 1, name = company
ID = 3, PID = 2, name = mission statement
ID = 4, PID = 1, name = login
Looking at this example, we can see that the first record is the home page, the mother page. This will not have a PID as it is the highest level and has no parent.
The second record has a PID of 1 to show that this record is a child of the home page.
The third record has a PID of 2 making the second record the parent of this one.
This technique is ideal for what you are after as it means you don't need multiple tables to accommodate the different levels in your hierarchy, and the hierarchy is unlimited. Although it is highly unlikely that you would go any deeper than maybe three levels, you have the luxury of having unlimited hierarchical scope.
Does this make sense?
Please feel free to contact me of you have any questions.
Many thanks,
Bookmarks