I’m trying to create a work schedule creator with multiple stores and each store with multiple employees. Each store can also access past schedule created, but only the current schedule is modifiable. The way I have my SQL database setup is that I have two tables, stores and employees. Each employee has a store they work for, and time for all the days of the week, so I saved employees from all the stores in one table and get them as necessary with queries.
My question is, should I add another column (week) to the employee table to designate which week that schedule is for, or create a new html file for each schedule for that store’s past schedules? I like the second choice because it decreases the chances of my SQL database being corrupted. As past schedules are unmodifiable, I have no issues with it.
P.S. just to make sure: if i write to a file using php, say $name = "monir"; write("My name is $name"). Will the file say "My name is $name" or "My name is monir"?
As the comments made by DA and the other solutions indicate, having a third table is the way to go. At a minimum, try having the following:
store:
id | name | address | etc.
employee:
id | first_name | last_name | etc.
schedule:
id | store_id | employee_id | week | date | start_time | end_time
While week is redundant since date is stored, it allows you to query much faster. You don’t need the archive/past bit because you can just query whether schedule.week is the current week or not.