How can one best represent this type of data in a relational database?
-
There a variable number of a particular Machine each uniquely serialized by the manufacturer.
-
Each Machine will be set up by the user to do variable number of the tasks that this type of machine is capable of.
-
All the machines will select from the same task list which itself may be altered
over time -
Finally each task will have a time setting which will vary from one machine to another.
The final condition seems to mess up my attempts to normalize this.
Machines :: Id, SerialNumber
Id is the primary key.
Tasks :: Id, Description
Id is the primary key.
MachineTasks :: MachineId, TaskId
MachineId and TaskId are the composite primary key. MachineId is a foreign key referencing Machines.Id. TaskId is a foreign key referencing Tasks.Id.
ScheduledMachineTasks :: MachineId, TaskId, Time
MachineId and TaskId are the composite primary key. MachineId and TaskId are a composite foreign key referencing MachineTasks.MachineId and MachineTasks.TaskId.
Note that this will only allow to schedule each task only once per machine and requires further extension if one task may be scheduled multiple times per machine.