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:

  1. When an Order is created, copy the Store and StoreItem into OrderStore and OrderStoreItem entities that will never be changed, even if the original entities are altered or removed. The Order will now automatically reference to the OrderStore and OrderStoreItem entities.

  2. When an Order is created, copy all necessary data as JSON into special fields in the Order 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.