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.
Author |
Topic |
Lockdev
Starting Member
2 Posts |
Posted - 2010-02-18 : 17:39:10
|
Hi,I am designing the database for an e-commerce site with multiple category levels till you reach the product. Some products are after the second category level and some are after the third or fourth category level. How do I know if we reached the last category level (and the next level is the product query)? I had 2 options. 1. When querying the current category row, I also get a subquery of count number of child categories. If there are 0, then I know that the next step is the product list.2. In each category row, I added a column "nextStep"Which option is better OR is there a better option?Thank you for your help. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-19 : 00:18:46
|
dont you have a category type field which stores type values like product?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
Lockdev
Starting Member
2 Posts |
Posted - 2010-02-22 : 14:01:01
|
Thank you Visakh. I have another design question. Which of the following is a better structure?Should I create separate tables for each category level: Tables Category1, Category2, Category3 etc. Category1 will have a primary key column Category1ID. Category2 will have a primary key column Category2ID and a foreign key Category1ID which ties records from category2 to category1. OR should I create one table with multiple categories and use a parentcategoryid column to tie children categories with their parents.Thank you for your help. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-23 : 09:42:16
|
I would suggest you to do it latter way. One table to hold entire hierarchy with level numbers may be------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|