Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The classic design approach would be (the star denotes the primary key column):</p> <pre><code>Product ProductId* CategoryId: FK to Category.CategroyId Name Category CategoryId* Name Property PropertyId* Name Type CategoryProperty CategoryId*: FK to Category.CategoryId PropertyId*: FK to Property.PropertyId ProductProperty ProductId*: FK to Product.ProductId PropertyId*: FK to Property.PropertyId ValueAsString </code></pre> <p>If you can live with the fact that every property value would go to the DB as a string and type conversion info is stored in the Property table, this layout would be enough.</p> <p>The query would go something like this:</p> <pre><code>SELECT Product.ProductId, Product.Name AS ProductName, Category.CategoryId, Category.Name AS CategoryName, Property.PropertyId, Property.Name AS PropertyName, Property.Type AS PropertyType, ProductProperty.ValueAsString FROM Product INNER JOIN Category ON Category.CategoryId = Product.CategoryId INENR JOIN CategoryProperty ON CategoryProperty.CategoryId = Category.CategoryId INNER JOIN Property ON Property.PropertyId = CategoryProperty.PropertyId INNER JOIN ProductProperty ON ProductProperty.PropertyId = Property.PropertyId AND ProductProperty.ProductId = Product.ProductId WHERE Product.ProductId = 1 </code></pre> <p>The more WHERE conditions you supply (conjunctively, e.g. using AND), the faster the query will be. If you have properly indexed your tables, that is. </p> <p>As it is, the solution is not ideal for a full text indexing situation. An additional table that stores all the text associated with a ProductId in a more denormalized way could help here. This table would need updating through triggers that listen for changes in the ProductProperty table.</p>
    singulars
    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.
    3. VO
      singulars
      1. This table or related slice is empty.
    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