Note that there are some explanatory texts on larger screens.

plurals
  1. POorder and order_lines tables - duplicate data or use versioning?
    primarykey
    data
    text
    <p>Is it bad to duplicate names and prices into order_lines tables (references from product and options tables)? </p> <p>I've have checked a few popular ecommerce open sources PHP scripts and it does it.</p> <p>Assume the following tables (quick example):</p> <p><code>product</code> table:</p> <pre><code>+------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | product_id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(150) | NO | | NULL | | +------------+--------------+------+-----+---------+----------------+ </code></pre> <p><code>options</code> table: (a product can have 1 or more options, eg: small, large, x-large, etc)</p> <pre><code>+------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | option_id | int(11) | NO | PRI | NULL | auto_increment | | product_id | int(11) | NO | | NULL | | | name | varchar(150) | NO | | NULL | | | price | decimal(6,2) | NO | | NULL | | +------------+--------------+------+-----+---------+----------------+ </code></pre> <p>Company will be getting about 5000 new orders daily, I am looking for a reasonable way how to design order, order_line tables? Do you duplicate names and prices into order_lines table? Hundreds of prices will be changed every few month from the <code>options</code> table. </p> <p>I have read about versioning (Type 2), im not sure how it actually work, from what I can understand I can add <code>version_id</code> field in the <code>product</code>, <code>options</code> and order_line tables. Whatever the MAX version_id is, its mean the latest version. It seem much easier than using StartDate and EndDate design.</p> <p>I am looking for the design methodology that can be done quick and reasonable. Not too complicated design. </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.
 

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