SQLScholar
Programmer
hey all,
I have two tables which look something like this:
[Category]
ID
Name
FK_catID
[Items]
ID
Name
FK_catID
So basically it builds a heirarchy. An Item is a member of a category and a category can be a member of a category.
So lets sugguest we are talking about Samsung E75 Laptop.
It would be in itself an item. The item would be in the category laptops. Laptops would be in the category electronics, and electronics would be in a category called things. Things would not have a fk_catID as it will be the top level. So we have
Things>
Electronics>
Laptops>
Samsung E75
Obviously there will be other things in each catergory, including other categoies or items. So under electronics may have Televisons for instance.
Now.... what i have is an issue. I think the table design is correct, but now i have been asked. If i have an Item id, i need to return the top most level that its a part of.
How can i do this?
Any help or guidance much appreciated.
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I have two tables which look something like this:
[Category]
ID
Name
FK_catID
[Items]
ID
Name
FK_catID
So basically it builds a heirarchy. An Item is a member of a category and a category can be a member of a category.
So lets sugguest we are talking about Samsung E75 Laptop.
It would be in itself an item. The item would be in the category laptops. Laptops would be in the category electronics, and electronics would be in a category called things. Things would not have a fk_catID as it will be the top level. So we have
Things>
Electronics>
Laptops>
Samsung E75
Obviously there will be other things in each catergory, including other categoies or items. So under electronics may have Televisons for instance.
Now.... what i have is an issue. I think the table design is correct, but now i have been asked. If i have an Item id, i need to return the top most level that its a part of.
How can i do this?
Any help or guidance much appreciated.
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------