Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have to make a database for a coffee shop and one of the tables i have to add is a preference table(what coffee drink members prefer). Which is the relation between coffee drinks and preferences? which is the relation betweeen members and preferences?

What I have tried:

i am not sure if i should create a join table to connect all of these relations( if they have many to many relation,i must do this) or i should add these as foreign keys to the preference table.
Posted
Updated 19-Jan-17 5:21am
Comments
F-ES Sitecore 19-Jan-17 10:53am    
Go over your class notes and if you're struggling then ask your tutor, no-one here is going to do your homework for you.
Richard Deeming 19-Jan-17 12:13pm    
Since multiple members can like the same drink, you'll clearly need a one-to-many relationship between drinks and preferences.

The question is, can one member prefer multiple drinks? If they can, it's a one-to-many. If not, it's a one-to-one.

You will have to ask the users who are going to use the software system, not us. This should be carried out at requirement phase of the software development life cycle[^] based on which your database is design. Introduction to database design[^]
 
Share this answer
 
v3
The Preference should relate to both the Member and the Drink table.

Let's say you have a table of available drinks (we'll call it Drink):

DrinkId | Drink
1 | Cappucino
2 | Latte
3 | Mocha
4 | Espresso
etc.

and a table of members (Member):

MemberId | Member
1 | Tom
2 | Dick
3 | Harry
etc.

A table of preferences (Preference) like this:

MemberId | DrinkId
1 | 3
3 | 4

would tell us that Tom likes Mocha and Harry likes Espresso.

Hopefully, you'll be able to see where the foreign keys should be applied - we need to ensure that on the Preference table, MemberId exists in Members and DrinkId exists in drinks, so that's the relational integrity that we need to establish with our foreign keys.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900