I'm designing the architecture of my application and I'm running into an issue. For the webshop every Order
entity has a relationship with a Store
and many StoreItem
's. This allows for quick fetching of information when a user wants to view the Order
.
However, when a StoreItem
is altered, or even worse, deleted, this information is no longer relevant/available when looking at the Order
entity. I have two possible solutions for this, and I would like your feedback on them:
When an
Order
is created, copy theStore
andStoreItem
intoOrderStore
andOrderStoreItem
entities that will never be changed, even if the original entities are altered or removed. TheOrder
will now automatically reference to theOrderStore
andOrderStoreItem
entities.When an
Order
is created, copy all necessary data as JSON into special fields in theOrder
entity. Every time data is requested, get the JSON and turn it into data the system can use.
If you know of a better way to do this, feel free to add it. I'm trying to keep everything relational, so no child objects/tables.