Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This sort of inheritance is always a bit trick with relational databases. What you have is one approach and it is the most traditional approach to the problem. You end up doing a lot of crossing of tables, but that might be just fine. </p> <p>Another approach is to employ some denormalization and collapse the tables into one table. Include a type field which represents the type of the item and then have the union of the fields all in that table. So you would have a table like </p> <pre><code>ID | GUID Type | GUID [FK] Name | nvarchar(64) State | int [FK] ZipCode | int Address | nvarchar(64) Name | varchar(64) Url | nvarchar(2048) Store | GUID [ FK ] Details | GUID [FK] ... </code></pre> <p>This means you have a bunch of empty fields in your table. </p> <p>You could also take a more fragmented approach and construct your tables like </p> <pre><code>Item: ID | GUID ItemPropertyType: ID | GUID Name | nvarchar(50) ItemProperty: ID | GUID ItemID | GUID [FK] ItemPropertyTypeID | GUID charValue | varchar(64) </code></pre> <p>Each item property references an item. To construct an item you simply gather up the ItemProperties which it owns. If you wanted to find all items where Name was 'bill' then you could do </p> <pre><code>select ItemID from ItemProperties ip, ItemPropertyTypes ipn where ipn.ID = ip.ItemPropertyTypeID and ipt.Name='Name' and ip.charValue='bill' </code></pre> <p>Jeff actually blogged a bit about this topic <a href="http://www.codinghorror.com/blog/2008/07/maybe-normalizing-isnt-normal.html" rel="nofollow noreferrer">http://www.codinghorror.com/blog/2008/07/maybe-normalizing-isnt-normal.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload