title: Best way to define relationships in an object model?
body: <p>When building an <code>object model</code> that map a <code>classes</code> to database tables, how do you specify the relationship to other entities ?</p>
  
  <p>Example :</p>
  
  <pre><code>Category
  ----------------------
  CategoryId  INT     PK
  Name        VARCHAR
  Description VARCHAR
  
  Product
  ----------------------
  ProductId   INT     PK
  CategoryId  INT     FK
  Name        VARCHAR
  UnitPrice   DECIMAL
  UnitInStock INT
  
  
  class Category 
  {
       public int CategoryId { get; set; }
       public string Name { get; set; }
       public List&lt;Product&gt; Products { get; set; } //for navigation only
  }
  
  class Product
  {
       public int ProductId { get; set; }
       public string Name { get; set; }
       public decimal UnitPrice { get; set; }
       public int UnitInStock { get; set; }
  }
  </code></pre>
  
  <p>What is the best way to define a relationship to the other entity ?  </p>
  
  <pre><code>class Product
  {
       //...
       public Category Category;
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>class Product
  {
       //...
       public int CategoryId;
  }
  </code></pre>
  
  <p>or both ? (one for database binding (<code>int CategoryId</code>) one for navigation (<code>Category 
  Category</code>)</p>
  
  <pre><code>class Product
  {
       //...
       public int CategoryId;
       public Category Category;
  }
  </code></pre>