title: Multiple Variations for Products Database
body: <p>I know there are lots of questions with same concern but i have gone through so many answers but unfortunately i didn't understand or may be not satisfied.</p>
  
  <p><strong>Goal</strong>
  I want my products can have multiple attributes and based on their combination they can have their price , sku and stock</p>
  
  <p><strong>Example</strong>
  T-shit product has size, color and material attributes (options)</p>
  
  <p>so i want this flexible strucute that</p>
  
  <blockquote>
    <p>Color: Red, Size: M , Material: Soft -> price $1, sku XXX, stock 3
    Color: Red, Size: L , Material: Soft -> price $2, sku XXX, stock 4
    Color: Black, Size: XL , Material: hard -> price $3, sKu XXX, stock 4</p>
  </blockquote>
  
  <p>Right now i have the following structure that is okay if only one attribute (option) is provided. But it does not fit for variations (combo).</p>
  
  <p><strong>Products Table</strong></p>
  
  <pre><code>CREATE TABLE `products` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `brand_id` int(11) DEFAULT NULL,
    `vendor_id` int(11) NOT NULL,
    `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `long_description` longtext COLLATE utf8_unicode_ci NOT NULL,
    `short_description` longtext COLLATE utf8_unicode_ci,
    `images` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `weight` decimal(8,2) NOT NULL,
    `discount` int(11) DEFAULT NULL,
    `discount_start` timestamp NULL DEFAULT NULL,
    `discount_end` timestamp NULL DEFAULT NULL,
    `status` tinyint(4) NOT NULL,
    `released_on` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  </code></pre>
  
  <p><strong>Options Table</strong></p>
  
  <pre><code>CREATE TABLE `options` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  </code></pre>
  
  <p><strong>Products_Options Table</strong></p>
  
  <pre><code>CREATE TABLE `products_options` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `product_id` int(11) NOT NULL,
    `sku` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `option_id` int(11) DEFAULT NULL,
    `option_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `unit_price` decimal(8,2) NOT NULL,
    `available_stock` int(11) NOT NULL,
    `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  </code></pre>
  
  <p>So the <code>products_options</code> table can store products in the following way</p>
  
  <pre><code>Color: Red -&gt; price $1, sku xxx, stock 3
  Size: M -&gt; price $1, sku xxx stock 3
  </code></pre>
  
  <p>But it does not reflect if i want to store color:red size:m having one price and sku and stock</p>
  
  <p>Thanks</p>