October 31st, 2002, 10:32 AM
Database Design Problems
Hey, I'll *try* to explain the problem im having...I need to know how to set up some tables.
I have a table called "projects" and each project has "requirements". I want there to be up to 4 levels (categories as I named the table) of requirements. BUT a requirement does not have to have a category, and a category obviously does not have to have a requirement. Also, how do I show the parent relationships?
For example how do I show that if category one, has category two below it, AND has a requirement below it? The Idea's i've had and I don't think are right, is having a "parent" table, which falls apart when you have a category, or requirement, with no parent (other than the project itself). Having just a category table, and having category 1, cagegory 2, category 3, and category 4 rows in my requirements table, which once again falls apart because it has no way of showing parent relationships for the categories *sigh*. I'm sure I should know this but my brain doesn't want to work right now. I hope that explains it somewhat. If not, feel free to e-mail me @ firstname.lastname@example.org and I'll even send you the database hah.
Any help would be greatly appreciated!!
October 31st, 2002, 10:43 AM
There are several threads involving this category / sub category issue that show several different methods of doing it. Search and see if you can find one. I would probably do it something like this. (and this is only one way)
1 My Project
ID parent category
1 0 label1
2 1 label2
3 0 label3
(label2 is a subcategory of label1)
ID project_ID category_ID requirement
1 1 2 Make it work right
(requirement is My Project and falls in the label2 category)
Explain your problem instead of asking how to do what you decided was the solution.
October 31st, 2002, 10:50 AM
Wow, thanks for the quick reply. I was getting confused for some reason about the category's parent. This head cold's gettin to me.