In DDD, in an aggregate root of Person with a Value Object of Address, mapping that address to a database table is simple: just embed the attributes of the Address object into the record. But what about when the Person has a List, where the count can vary? Do we create a separate table that stores all our Addresses (thereby imposing some quasi-identity on each one), and each row with an FK back to the Person to which it belongs?
1 Answers
2
votes
There is a good example of object-relational impedance mismatch. What you can do is have a layer super-type where persistence concerns such as an id field lives. Therefore, from your persistence layer's point of view, the VO is an entity, but still modeled as a VO in the domain.
You can read more about the above here.