Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Categories and sub categories best practice

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2007-08-09 : 16:05:01
I have an application which has a database table called Category. Its very simple, with fields id and categoryname.

My client now wants functionality for sub categories. Whats the best way to do this. My initial thought was to keep the same database table but have a 3rd column called ParentID which contains the ID of the parent category.

Is this the best way? Or something else.

Thanks

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-08-10 : 01:34:56
Have you thought of creating a subcategory table which holds a subcategoryid as the Primary Key and a categoryID which has a foreign key relationship with the categoryid on the category table?


Duane.
Go to Top of Page

hshot_rooke
Starting Member

8 Posts

Posted - 2007-10-04 : 16:13:12
I posted our hierarchical structure we are using in another thread. It's a little sparse, sorry, but it is a lot to explain in a forum post.

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86268[/url]


We do exactly what you need to do as we are a movie company that needs parent/child relationships for categories/subcategories.
Hope it helps a little. My post is near the bottom of first page.
Go to Top of Page
   

- Advertisement -