DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Database Design (http://www.daniweb.com/forums/forum142.html)
-   -   expandable tables? (http://www.daniweb.com/forums/thread121693.html)

jinx_uk_98 Apr 30th, 2008 5:17 am
expandable tables?
 
Hi,

I'm creating a web database as a bit of learning project.

In short it's going to a on-line menu viewer, where people can upload (type in) their food/takeaway food menus.

The problem I'm having is with the design and as each outlet can have a differing number of starters/mains/deserts etc..

inital thoughts were:

Menus
------
Menu_id
Menu_outlet
Starter1
Starter2
Starter3
Starter4
etc...

but what if an outlet has more that 4 starters?

Can anyone point me in the right direction please?

thanks jinx

bcasp Apr 30th, 2008 3:23 pm
Re: expandable tables?
 
Do some research on normalization.

You might want to consider a simple setup where you have three tables.

Menu
MenuID (Primary Key)
MenuOutlet

Starter
StarterID (Primary Key)
StarterDescription

MenuStarter
MenuID (Primary Key - 1)
StarterID (Primary Key - 2)

This setup allows you to have as many starters as you want for each menu. The MenuStarter table would just use a concatenated primary key that could link those two tables. Hope this makes sense...

Again, some research on normalization would probably help.

trudge May 1st, 2008 2:23 am
Re: expandable tables?
 
bcasp is pointing you in the right direction. As a further enlightenment, any time you ask yourself the question 'what if column X has more than Y choices' is an indication that that column should be broken out into a separate table.

jinx_uk_98 May 8th, 2008 9:16 am
Re: expandable tables?
 
thats great guys, many thanks


All times are GMT -4. The time now is 1:54 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC