Forum Moderators: open
Could you not set up your table like thus:
CatID ¦ Category ¦ ParentCatID
This way you have:
1 ¦ Computers ¦ 0
2 ¦ Monitor ¦ 1
3 ¦ Input Devices ¦ 1
4 ¦ Mouse ¦ 3
5 ¦ Keyboard ¦ 3
6 ¦ CPU ¦ 1
Therefore Keyboard would be listed as:
Computers -> Input Devices -> Keyboard
JP
If you are after more of a relational Ontology where a parent can have many shildren, and a child can have many parents (?), then you would need a third linking table to handle all the relationships.
I tend to use a limited Ontology by limiting myself to a 2 to many relationship, ie, a child can only have two parents, which seems to cover most situations, by adding a fourth field thus:-
CatID ¦ Category ¦ ParentCatID ¦ RelatedParentCatID
A little limiting but as I say it seems to cover most situations and would also be a little faster that a pure Ontological structure.
Onya
Woz
NODES TABLE
NODE ID ¦ NODE NAME ¦ NODE DATA
RELATION TABLE
PARENT ID ¦ CHILD ID
This also gives you the later flexibility of switching to 3 or 52 parents, or varying it per node - some nodes have 2, some have 6.