You would solve this in a RDBMS the same way: de-normalize when you're saving the invoice (example: a line items table with snap shot of current item price, description, etc.)
Yes, which suggests that the "serious problems" mentioned by the grandparent aren't serious (or problems) at all.
Re:The Marketing Behind MongoDB
by purerandomness on Thursday August 31, 2017 @11:39AM
(#15141054)
In Postgres, you'd simply have a table with a JSON column for the snapshot-in-type contract.
You can then select fields from that JSON for invoices, reports, etc with the arrow operator:
https://www.postgresql.org/docs/9.6/static/functions-json.ht...
With SQL you can denormalize all that (and should) to create that snapshot. But with NoSQL you can't normalize and get back a way to quickly query the number of products sold per month over the last 5 years.
Re:The Marketing Behind MongoDB
by chrisco255 on Tuesday August 29, 2017 @07:15PM
(#15128420)
Yes, this is possible with Aggregation and MapReduce: https://docs.mongodb.com/manual/aggregation/
Except, oops, your user got married and moved, now your precious "referential integrity" means jack because the generated invoice is flat-out wrong. Product removed from the store? Too bad, needs to stay in the database forever for historical purposes. Prices need to change? Better design the database to handle snapshots of every product state.
If you were implementing this in MongoDB, you'd probably store a UUID and the flattened data at the time of invoice generation, that way you can still query on ids AND not deal with the headache of having a combinatorial explosion of data in your RDBMS.