Frage

I am working a scenario where I have a parent item called "TEAM", with a 1 to many of "COACHES" AND "PLAYERS". The team, coach, and players each have a parentid column in their table that referencing a parent item in that same table. These teams can join events which have a certain end date, or can be archived. Once a team joins an event, I create a child copy of the parent since that team may change in the future, but should stay the same once the event has past. I am using SQL Server and thinking the best way to do this is triggers. Once something is updated, added, or deleted from the parent propagate it to the child. If the event has passed or has been archived then don't update, add, or delete anything in the child. Is there a better way to do this?

War es hilfreich?

Lösung 2

I just went with a parent/child relationship of the same table. Any updates to the parent will cascade to the child via code unless a certain date has passed.

Andere Tipps

This sounds similar to making a table auditable. Not sure if this is better, but you might make the team read only, and whenever the team changes create a new team record, with each team record having startdatetime and enddatetime, with current teams having null enddatetime. That way events will always have a reference to the team as it was when the team joined the event.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top