Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > General > Database Concepts & Design > Link Tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-07, 13:26
abch624 abch624 is offline
Registered User
 
Join Date: Oct 2007
Posts: 5
Question Link Tables

Hi,

I want to implement a functionality in a database so that a menu can hold as many drinks and as many food items as possible. I am using a Link table for this functionality.

Please have a look at the link Tables.doc file attached. There is a picture (er diagram) of part of the database.

Your help might help...

Thanks - Zahid
Attached Files
File Type: doc Link Tables.doc (32.0 KB, 35 views)
Reply With Quote
  #2 (permalink)  
Old 10-27-07, 14:15
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
how many menus are you planning to have?
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #3 (permalink)  
Old 10-27-07, 14:41
abch624 abch624 is offline
Registered User
 
Join Date: Oct 2007
Posts: 5
I am planning to have one menu. To be a bit more specific. There would be one venue table which would have the menu table as a foreign key. Hope that explains it.

Thanks - Zahid
Reply With Quote
  #4 (permalink)  
Old 10-27-07, 16:55
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
i have a wonderful idea -- if there's only going to be one menu/venue, you don't need a table for it

instead, just assume that every food and drink is on it

do not enter any foods or drinks into the food or drink tables that aren't on the menu/venue

simple, yes?
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #5 (permalink)  
Old 10-27-07, 18:18
abch624 abch624 is offline
Registered User
 
Join Date: Oct 2007
Posts: 5
Hi,

Ummm...
There is going to be a number of venues and every venue will have its own menu (i.e. In reality there are a number of restaurants with one menu or more and one menu has lots of drinks and lots of food items). If we consider a website like www.toptable.com a restaurant has one menu and and lots of drinks and food items.

Coming to what you said it means that I need to have a fixed number of food items and drink items in the menu. I don't want to restrict the design by adding a fixed number of keys.

I hope I am not being ambiguous and unclear.

Thanks - Zahid
Reply With Quote
  #6 (permalink)  
Old 10-27-07, 19:04
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
no, not ambiguous or unclear, although this now contradicts what you said in post #3

okay, let's have a Menus table, a Foods table, and a Drinks table

now add two more tables, each of which will be a many-to-many relationship table -- MenuFoods and MenuDrinks

each of these tables will consist of only two columns: the foreign keys to the related tables
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #7 (permalink)  
Old 10-27-07, 22:17
abch624 abch624 is offline
Registered User
 
Join Date: Oct 2007
Posts: 5
Hi,

Thanks a lot for that.
I nearly understand now how to do it but have a problem still. Please have a look at the attachment.

Your help has been grate.

Thanks - Zahid
Attached Files
File Type: doc Link Tables1.doc (91.0 KB, 34 views)
Reply With Quote
  #8 (permalink)  
Old 10-27-07, 22:24
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
Venues
1001 Todd's Restaurant
1002 Biff's Steakhouse

Menus
21 1001 Lunch at Todd's
22 1001 Dinner at Todd's
23 1002 Biff's Allday Menu

Foods
54 New York Steak
56 Cabbage
57 Potatoes
58 Ice Cream

Drinks
78 Beer
79 Whiskey
83 Sambuca

MenuFoods
21 56
21 57
22 54
22 57

MenuDrinks
21 78
21 79
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #9 (permalink)  
Old 10-28-07, 07:11
abch624 abch624 is offline
Registered User
 
Join Date: Oct 2007
Posts: 5
Smile

Thanks a lot.

You have been of grate help, I now understand. In the future I might have more questions but for now you have cleared this one .

Thanks - Zahid
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

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