Should you update child states based on the parent

application-designdatabase-design

I have the following table structure

Event –* Session –* Membership

  • An event can be cancelled – reflected via a status column
  • A Session can be cancelled – reflected via a status column
  • A user can attend or leave an event via the membership row

My design questions

If an event is cancelled, should all of the session rows be marked as cancelled as well?

Likewise, if a session is cancelled should the membership row also be marked as cancelled?

What are the pros and cons to these methods?

Best Answer

It's opinion based, but I would err on the side of updating the bare minimum when a status changes.

  • If you cancel an event and only update the Event row indicating cancelled then you minimize the amount of data that would need to be updated should the event be reinstated.
  • Likewise, if you cancel a session, and only update the Session row indicating cancelled then you minimize the amount of data that would need to be updated _should the session be reinstated.
  • As Joe W points out in a comment:

if you do update the sessions as well if there was sessions canceled for other reasons you would have a harder time getting the status correct if you un-cancel an event as you might not know exactly which sessions should still be canceled.