I think your ERD diagram looks pretty good, but I noticed a couple things:
- It looks like your
MealTable
table will be having more than one row per meal, so I would rename it toMealFood
to list all the food items in each meal. If you need to add fields to each meal (such as the name of the meal), then make a separate table calledMeal
that will have just one row per meal - I would remove
day_id
fromDietTable
and instead have adiet_id
column in thedayOfTheWeek
table. If you pair this with amealOfTheDay
column, you could make a unique key acrossdiet_id, day_id, mealOfTheDay
to make sure each diet only has one meal for each meal of the day
Example dayOfTheWeek
table:
| diet_id | day_id | mealOfTheDay | meal_id |
---------------------------------------------
| 1 | 1 | 1 | 999 |
| 1 | 1 | 2 | 642 |
| 1 | 1 | 3 | 242 |
| 1 | 1 | 4 | 298 |
| 1 | 1 | 5 | 322 |
| 1 | 1 | 5 | 111 | <- Unique key will not allow
this row as it's the second
fifth meal on same day for
diet 1
- Also, try to keep you naming consistent. Some of you table names end with
Table
and some don't.