title: Database schema design for records of nested JSON
body: <p>I have a list of <code>profile</code> records, which each of the record is like the below:</p>
  
  <pre><code>{
    "name": "Peter Pan",
    "contacts": [
      {
        "key": "mobile",
        "value": "1234-5678"
      }
    ],
    "addresses": [
      {
        "key": "postal",
        "value": "2356 W. Manchester Ave.\nSomewhere District\nA Country"
      },
      {
        "key": "po",
        "value": "PO Box 1234"
      }
    ],
    "emails": [
      {
        "key": "work",
        "value": "abc@work.com"
      },
      {
        "key": "personal",
        "value": "abc@personal.com"
      }
    ],
    "url": "http://www.example.com/"
  }
  </code></pre>
  
  <p>I would think about having the following schema structure:</p>
  
  <ol>
  <li>A <code>profile</code> table with <code>id</code> and <code>name</code> field.</li>
  <li>A <code>profile_contact</code> table with <code>id</code>, <code>profile_id</code>, <code>key</code>, <code>value</code> field.</li>
  <li>A <code>profile_address</code> table with <code>id</code>, <code>profile_id</code>, <code>key</code>, <code>value</code> field.</li>
  <li>A <code>profile_email</code> table with <code>id</code>, <code>profile_id</code>, <code>key</code>, <code>value</code> field.</li>
  </ol>
  
  <p>However, I think I am creating too many tables for such a simple JSON!</p>
  
  <ol>
  <li>Would there be performance problems when I search across the tables, since many JOINS are performed to retrieve just one record?</li>
  <li>What would be a better way to model the above JSON record into the database? In SQL, or better in NoSQL?</li>
  </ol>