0

I have similar scenario in Domain Driven Design Question on Services and Repositories and http://pastie.org/795679 which the azamsharp faces.

Since registration is value object, and user can have list of value objects, how can i save this registrations in user table because there is 1 to M relationship between User and Registration. Do i have to create seperate table for registration.

Community
  • 1
  • 1
chandra
  • 313
  • 1
  • 3
  • 8

1 Answers1

0

DDD or no DDD, it you have a 1-M relationship, the cleanest solution is a separate Registration table, with an FK back to the User.

Just because Registrations are Value objects, doesn't mean that you have to save them in the User table. It's a common misconception with DDD newbies. Maybe this answer can help.

Community
  • 1
  • 1
Vijay Patel
  • 17,094
  • 6
  • 31
  • 35
  • Thanks Vijay , but do my Registration table can have ID acting as surrogate key , or only foreign key pointing to User table because this article http://stackoverflow.com/questions/949320/ddd-value-objects-and-orm says we should not have ID in value object table – chandra Dec 09 '10 at 12:50
  • That answer only applies if you have a fixed number of Value Objects. Your 'Registration' definitely needs an FK back to the 'User'. A surrogate key is optional (you might need one as your requirements evolve). – Vijay Patel Dec 09 '10 at 14:00