Food and Databases...

robbluther's picture

He has: 73 posts

Joined: Jan 2006

I am making a database of menu items for a restaurant. If I want to display the items based on what menu they beling on... dessert, appetizers... etc... would you make a seperate table for each and query each table into the site? Or have and identifier fireld and seperate them with script on the page?

Thanks

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

I fell it wwould really depend on the size of th menu, if you have say only 5-10 items of most categories, then I would use just one table with a colum to indicate category.

Also would depend what the database is for, ie. For customers to place orders, for the management to pick and choose what menu items area available on a given day?

-Greg

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

I would absolutely just do an identifier field. Then, you can handle everything within the SQL statement itself.

robbluther's picture

He has: 73 posts

Joined: Jan 2006

Tim, that is kinda the way I was leaning, all the DB is for is so that the owner can update the menu on the web page by himself... He has daily specials and things like that...

They have: 13 posts

Joined: Jan 2006

cross link tables, in other words, one table just consists of the "categories"
the category holds the info to fill in, such as MID, NAME

e.g.
1 Breakfast
2 Lunch
3 Dinner
4 Desserts

MID would be a primary key to that category
then you would fill in all items into the main table, and include a field for the KEY
which would then assossciate that item

say ID, cupcakes, Item Cost, MID
insert '', 'cupcakes' '5.99', '4'

You can then query all MID 4 and it will display Name "Desserts"
and all items in desserts tagged by being MID 4

// get those deserts, im hungry
select table.ID,table.ItemCost, menutable.MID, menutable.NAME from table,menutable where table.MID = '4'

echo those desserts...

1 $5.99 4 cupcakes

above is not perfect but you should get the idea

Regards,
Bugmaster
http://www.logowars.com - Graphics Gone Mayhem

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.