Saurabh wrote:
The category table has a primary key called 'CategoryId' . This key is also a foreign key.
There is another table called LINK. The primary key for this table is 'LinkID' and it is associated with the category table through a foreign key (categoryID). The link is the lowest level member in the hierarchy. It will not have any children but will have a category/subcategory as its parent.
Saurabh,
From what you have described it appears like you are maintaining parent-child relationship for the same set of data in a separate table. The mapping for this could be done in two different ways.
If each parent can have only one child and each child can have only one parent, the relationship would be a one-to-one.
If each parent can have multiple children and each child can have only one parent it is a one-to-many.
If each parent can have only one child but each child can have multiple parents, the relationship would be a many-to-one.
If each parent can have multiple children and each child can have multiple parents, the relationship would be a many-to-many.