2 quick questions:
I have done my best to learn about normalization forms, but wasn’t sure about this specific situation.
- I have an Event.
- An Event has many Instances.
- An Instance has: Food, People, Cost, Evaluation, Location, etc.
Should food, people, cost, etc. each get their own table or simply be columns in the Instance table (BLOBs)? I have no reason to think they would need a full table each, since they belong only to an Instance, and would not be shared. However…I don’t know if the future may give me reason for them to be their own, so is it better to just treat them as their own?
Secondly, IF all of those should each be their own table, is it useful to also store the Event foreign key as well? In case I want to call every Food list for an event regardless of instance, or would I just get all the instances from an event and then call the info for each instance. If I expect that call to happen, is that enough cause to add the key or is this poor planning?
Might as well plan for the future here and now before you get down the road and regret your decision later. It would probably be better to store your Instance Items (Food, People, Cost, etc) in separate tables. Instance -> Instance Item is a many to many relationship, you’ll need some linking tables in between the object tables to allow this many-to-many relationship.
In the case of the linking tables, the primaryKey is the combination of both the InstanceID and the other id value. With this setup, there is no need to store event IDs in your object (food, person) tables. If you wanted to figure out which events a particular person is associated with, just join Person with Instance Person and Instance to get all associated EventIDs.