title: DDD Value Object: How to persist entity objects without tons of SQL joins?
body: <p>Obviously I am wrong in saying that DDD is similar to EAV/CR in usefulness, but the only difference I see so far is physical tables build for each entity with lots of joins rather than three tables and lots of joins.</p>
  
  <p>This must be due to my lack of DDD understanding.  <strong>How do you physically store these objects to the database without significant joins and complication when importing data?</strong>  I know you can simply create objects that feed in to your repository, but it's difficult to train tools like Microsoft Sql Server Integration Server to use your custom C# objects and framework.  Maybe that should be my question, how do you use your DDD ASP.NET C# framework with Microsoft SQL Server Integration Services and Report Services? LOL.</p>
  
  <p>In an EAV/CR database, we can setup a single Person table with different classes depending on the type of person: Vendor, Customer, Buyer, Representative, Company, Janitor, etc.  Three tables, a few joins, attributes are always string with validation before we insert, just like ModelValidation in MVC where the object accepts any value but won't persist until it's valid.</p>
  
  <p>In a standard relational model, we used to create a table for each type of entity, mixing in redundant data types like City.</p>
  
  <p>Using Domain Driven Design, we use objects to represent each type of entity, nested objects for each type of ValueObject, and more nested objects still as necessary.  In my understanding, this results in a table for each kind of entity and a table for each kind of information set (value object).  With all these tables, I see a lot of joins.  We also end up creating a physical table for each new contact type.  Obviously there is a better way, so I must be incorrect in how I persist objects to a database.</p>
  
  <p>My Vendor looks like this:</p>
  
  <pre><code>public class Vendor {
      public int vendorID {get; set;}
      public Address vAddress {get; set;}
      public Representative vRep {get;set;}
      public Buyer vBuyer {get; set;}
  }
  </code></pre>
  
  <p>My Buyer:</p>
  
  <pre><code>public class Buyer {
     public int buyerID {get; set;}
     public Address bAddress {get; set;}
     public Email bEmail {get; set;}
     public Phone bPhone {get; set;}
     public Phone bFax (get; set;}
  }
  </code></pre>
  
  <p>Do we really reference things like Vendor.vBuyer.bPhone.pAreaCode?  I would think we would reference and store Vendor.BuyerPhoneNumber, and build the objects almost like aliases to these parts: Vendor.Address1, Vendor.Address2, Vendor.BuyerPhoneNumber ... etc.</p>