0

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?

BCA
  • 7,776
  • 3
  • 38
  • 53

1 Answers1

2

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.

plalx
  • 42,889
  • 6
  • 74
  • 90
  • Thanks for the insight and the link. I know this is off topic but in your opinion is NHibernate superior to Entity Framework for the task of supporting DDD? – BCA Apr 23 '15 at 15:16
  • @BCA, I never used Entity Framework unfortunately, but Vaughn Vernon blogged on how to efficiently use Entity Framework https://vaughnvernon.co/?p=879 – plalx Apr 24 '15 at 03:36