Event management schema design
I am designing an event management system (to be used for personal events like bdays etc + corporate events + campaign events). The relationships are Event belongs to a Campaign, Events have days and days have sessions. At the same time each of these: (Campaign, Event, Day, Session) can h开发者_C百科ave the same attributes like Budget, Goal, Mission, etc. So should these be stored in their own tables like an event_mission, event_goal, event_budget table or should they be thrown in as columns in the (event, campaing, days, session) tables?
There are other attributes like: Location, Area within a location, People invited, people attending, etc that fit into each of the above, so again I can combine them into their own tables for all like event_loc, campaing_loc, days_loc, session_loc or break them up at each level with one location table and have flags for each level.
Ofcourse this is only applicable for promotional events not personal events.
My opinion is that if it's a parameter (like location description, or maximal budget value) it should go inside each table.
If there could be many relationships - like event has many people attending - it should have separate table.
@koressak answer is correct. Basically if a Campaign can have only one budget, then store that budget in the same table as the Campaign... same rule for the others. But think about if you'd need to keep a history of what the budget figure was over time... e.g. if the budget was increased. Do you need to keep a history? If not, then the above is fine; otherwise break it out to a separate table. If you use a single table to store all those budgets, it will work but your code will be more tricky.
精彩评论