I have task to do some task in some items, and the same task for the same item, can be done in different periods (every 1 day, 2 days... etc). Also In need some material for this tasks, that it depends on the task, but some some tasks in some periods don't need material in another cases it needs.
So my first idea it would be to have this table:
TaskOfItemsOnPeriodWithMaterials
{
IDItem;
IDTask;
IDPeriod;
IDMaterial;
AMountOfMaterial;
}
In this case, the primary key would be IDTiem, IDTask, IDPeriod, IDMaterial
.
But if IDMaterial
is part of the key, it can't be null, so I couldn't have task in items in one period that doesn't have materials because it is needed.
So I think if IDMaterial
has to be primary key, because in fact it is a condition of unique value, perhaps I need another table, something like that:
TaskOfItemsOnPeriod
{
IDItem;
IDTask;
IDPeriod;
}
So I had to maintain two tables.
But I am wondering if it there would be a better solution.
Thanks.