#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    2
    Rep Power
    0

    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 @ bboy_snap@hotmail.com and I'll even send you the database hah.

    Any help would be greatly appreciated!!
    Thank you.

    Pat
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    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)

    table.projects
    ID name
    1 My Project

    table.categories
    ID parent category
    1 0 label1
    2 1 label2
    3 0 label3

    (label2 is a subcategory of label1)

    table.requirements
    ID project_ID category_ID requirement
    1 1 2 Make it work right

    (requirement is My Project and falls in the label2 category)
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    2
    Rep Power
    0

    Thanks!


    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.

    Thanks again

    Pat

IMN logo majestic logo threadwatch logo seochat tools logo