title: Most Performant Way to Store Non-Standard Data
body: <h2>Background</h2>
  <p>I have to store information about a set of products. This information is going to be pulled out via PHP onto a website, possibly in conjunction with WordPress, possibly using raw PHP. The problem is that these products have inconsistent attributes. Example:</p>
  <p>Product A</p>
  <ul>
  <li>Width =&gt; 6&quot;</li>
  <li>Height =&gt; 5&quot;</li>
  <li>Weight =&gt; 2 lb</li>
  <li>Color =&gt; Black</li>
  </ul>
  <p>Product B</p>
  <ul>
  <li>Weight =&gt; 3lb</li>
  <li>Manufacturer =&gt; Microsoft</li>
  <li>Date =&gt; 2015-02-01</li>
  </ul>
  <p>The simple answer is a single table in SQL, with an ever expanding number of columns, most of them empty, to cover every possible attribute. I don't think that is the way to go though, given the number of possible attributes and the need for extensibility.</p>
  <hr />
  <h2>Idea 1</h2>
  <p>One thought I have is to set up one table, with each row being a product, and having an ID. A second table will have every row be an attribute, linked by the product ID.</p>
  <p><strong>Table 1</strong></p>
  <pre><code>Product | ID
  Phone   | 0001
  Table   | 0002
  </code></pre>
  <p><strong>Table 2</strong></p>
  <pre><code>Product ID | ID   | Attribute Label | Attribute Value
  0001       | 0001 | Height          | 2&quot;
  0001       | 0002 | Width           | 3&quot;
  0001       | 0003 | Weight          | 2lb
  0002       | 0004 | Company         | Apple
  0002       | 0005 | Color           | Black
  0002       | 0006 | Weight          | 2lb
  </code></pre>
  <p>The problem I see with this is that table 2 gets massive in number of rows.</p>
  <hr />
  <h2>Idea 2</h2>
  <p>Nested Array, stored Somehow</p>
  <p><strong>Table</strong></p>
  <pre><code>Product | Attributes | ID
  Phone   | ARRAY      | 0001
  Table   | ARRAY      | 0002
  </code></pre>
  <p>Where I have the <code>ARRAY</code> be an array of key-value pairs. Serialized maybe, and stored? I could have an unlimited set of key-value pairs I would think.</p>
  <hr />
  <h1>My Question</h1>
  <p>What is the most performant way to achieve storing this sort of data? Are there best practices? Is there a different type of database entirely? I've heard the phrase JSON, could it be useful here?</p>