title: How can you represent inheritance in a database?
body: <p>I'm thinking about how to represent a complex structure in a SQL Server database.</p>
  
  <p>Consider an application that needs to store details of a family of objects, which share some attributes, but have many others not common. For example, a commercial insurance package may include liability, motor, property and indemnity cover within the same policy record.</p>
  
  <p>It is trivial to implement this in C#, etc, as you can create a Policy with a collection of Sections, where Section is inherited as required for the various types of cover. However, relational databases don't seem to allow this easily.</p>
  
  <p>I can see that there are two main choices:</p>
  
  <ol>
  <li><p>Create a Policy table, then a Sections table, with all the fields required, for all possible variations, most of which would be null.  </p></li>
  <li><p>Create a Policy table and numerous Section tables, one for each kind of cover.</p></li>
  </ol>
  
  <p>Both of these alternatives seem unsatisfactory, especially as it is necessary to write queries across all Sections, which would involve numerous joins, or numerous null-checks.</p>
  
  <p>What is the best practice for this scenario?</p>