Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009

    Database Design for newbie

    Hi people,

    Kind of new to designing databases and would like some help on the following.

    I have a database with 2 sections, services and styles.

    section_id, section_name
    1, services
    2, styles

    I have another table with a list of subsections for each main section linked using the section_id.
    (sub_section_id, sub_section_name, section_id)

    In my products table i have a list of products.
    (product_id, product_name, product_description, product_image)

    Here is my problem, each product falls under multiple subsections...for example,

    A product might fall under the subsection dark and also under the subsection minimal, so when the user clicks on either of these links on the page, the product is then returned under that subsection.

    How would i go about setting something like that up in the database, being new to this im a little confused.


  2. #2
    Join Date
    Nov 2004
    out on a limb
    so have a table which allows multiple sections for a single prodcut (often called an intersection tabel, I tend to call 'em xref tables becuase the cross reference other tables)

    intersectiontable (lets be dull and call it ProductSections)
    product 'fk to product table
    Section 'fk to sections table

    as a wrinkle on this design you can create a tree structure in your section table by identifying a parent section
    say you were modelling a food shop, you may have categories of produce.
    ID Name parent ID
    01 Produce
    02 Fruit 01
    10 Vegetable 01
    90 Citrus 02
    80 Oranges 90
    75 Manadarin 80
    76 Blood Oranges 80
    ..and so on

    that would allow your users to drill down product/categories (till they find the catgories they want), and it also allows you to show similar categories (eg if they select 'mandarins' you could suggest other citrus fruits on the same level, and the level above)

    if you allow users to say specify mulitple attributes then you will be able to query the db requesting any item which has the followign attributes. obviously that wouldn't work for my produce example above as an orange is an orange, a citrus fruit, a fruit. but its not an orange and a lemon at the same time.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts