If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Database Design for newbie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-08-09, 23:46
keggis keggis is offline
Registered User
 
Join Date: Mar 2009
Posts: 1
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.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-09-09, 03:45
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
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)

eg
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
...ferinstance
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On