Database / Model design for One to many, but only 1 active.
Hi all,
I wanted to get some feedback on how to approach the design of a database / models for the given scenario:
Let's say we have an organization that can have one or more contracts. These contracts are not considered ready to be viewed unless they are published/finalized. At the same time, the organization only wants to have one contract "active" at a time so that users who are viewing them are providing their consent to a specific, active, published version. The organization would also like the ability to activate both older and newer versions of their contracts on demand.
@noleafclover614 Unless I don't fully understand what you need, it sounds like you need a contracts table with an organization_id to associate contracts with the correct organization. Also, you will need a column like active_contract_id in the organizations table to hold the current active contract.
The organization should be able to watch all their contracts easily, both old and new (the contracts table has an organization_id column) and pick one of them to be active (which will set the active_contract_id column value on the organizations table's record).