Snapshot pattern: how to represent colection properties?

15 Views Asked by At

I'm taking a look at the Snapshot Design Pattern as a strategy to guarantee that my database is immutable (only inserts should be allowed). When looking at simple properties (ie, 1-1), the strategy presented on the link makes sense (ie, Firstname and Lastname. However, what's the recommended approach for mapping collections? For instance, suppose that Customer has a collection of Contact objects (which are value objects). When using regular tables, then we'd have 2 tables: one for Customer (one line for each customer) and another for Contact (one or more lines for each customer).

When applying the Snapshot pattern, we transform the Customer table into 2 (ex.: Customer and CustomerDetails). What's the recommended transformation for the Contact table? Should the contacts be serialized into a single line (say, by using json) so that the Contact tables "behaves" like the CustomerDetails table?

Thanks.

0

There are 0 best solutions below