Note that there are some explanatory texts on larger screens.

plurals
  1. PODB schema question, products types
    text
    copied!<p>My question is how to model transactions for different types of products.</p> <p>So there is a Transactions table:</p> <pre><code>TransactionId(pk) Amount Method AuthorisedBy(fk) </code></pre> <p>And there are different tables for different types of products. Books table:</p> <pre><code>BookId(pk) Name Description Price </code></pre> <p>And a Pens table:</p> <pre><code>PenId(pk) Color Description Price </code></pre> <p>And a table for pencil sharpening services:</p> <pre><code>SharpenId(pk) Description Price </code></pre> <hr> <p>Now my question is linking the transactions with the particular id's of the different items. One method was to have in the transaction table:</p> <pre><code>TransactionId(pk) Amount Method AuthorisedBy ProductType ProductTypeId(fk) </code></pre> <p>Where product type would refer to the title of the table, eg Books and the product id would refer to the BookId in that case.</p> <p>OR another method would be to have a linking table of 'products' that refer to each different id of the other tables, so the Transaction table would look like this:</p> <pre><code>TransactionId(pk) Amount Method AuthorisedBy ProductID(fk) </code></pre> <p>and the products table would look like this:</p> <pre><code>ProductId(pk) PoductType ProductTypeId(fk) </code></pre> <p>But then this is a table that is exactly the same as the transactions table. So my question is how do I efficiently link the different product type tables to the transactions? Please note I am not modelling a school pencil sharpening service, they're just examples :P </p>
 

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