ECommerce
ECommerce

Reputation: 469

Three tables have a many to many relationship to one Table

I'm wondering if this situation makes sense: I have three Entities which are called(Breakfast, Lunch and Dinner). Now I want to have a relationship to the Entity Food. Each Entity(Breakf,Lunch,Dinner) exists of one or multiple food entitites. One Food Entity can exist only once in each entity of (Breakfast, Lunch, Dinner) because it has an attribute amount. In this case I proably need a special Primary Key for each Food entity to provide the uniqueness of a food entity in an entity(Break,Lunch,Dinner).

Can somebody help to model the relationships? Is it simply a one to many relationship from each (Break,Lunch, Dinner) to Food?

Upvotes: 1

Views: 618

Answers (1)

doctacular
doctacular

Reputation: 11

So the model depends on if you need to be able to scale the number of meals... If 3 meals is static then you could store this information in one table:

ID | food_name | breakfast_amount | Lunch_amount | Dinner_amount | insert_date

Upvotes: 1

Related Questions