I've these tables:
Days
day_id day
1 Monday
2 Tuesday
schedule
schedule_id session
1 Start
2 Breakfast
3 Lunch
Ingredients
ing_id ing_name
1 Whey Protein
2 Havermout
3 Water Cup
and main_table
week_id | (user_id) | (day_id) | (schedule_id) | (ingredient_id) | grams
NOTE:
Columns surrounded by parenthesis in the main_table
are foreign Keys
from their respective tables.
Here is what I want to achieve:
For example I want to populate the data in main_table something like
(I've populated this table manually)
I want to keep the first four column's data (in main_table
) as constant until the schedule_id
does not change , and insert new data in the next two columns i.e ingredients_id
and grams
.
Because it works like this: Each week has days, days has sessions and in different session/timings user would be able to eat different ingredients.
Meaning that for one specific week, number of days could be repeated as
and for one day number of schedule session can be repeated , similarly for each schedule session there could be many ingredients.
How can I make some data as constant for some columns, and update some columns while inserting.
Do I need to change the structure of my tables, if so please suggest any other way to achieve this .
I really tried my best to explain my problem in simple way.
Thanks