title: MySQL+PHP: Storing data as JSON vs joins
body: <p>I am planing a new database structure for my project and now I am thinking about storing data inside a json-field, instead of creating some joined tables.</p>
  
  <p>I know, that I shouldn't store data into json-fields, which I want to use in WHERE, ORDER BY or similar  commands. But whats about simple 1:n text data?</p>
  
  <p>For example:</p>
  
  <pre><code>Table: cities
  ---------------
  id          int
  name        string
  districts   string (JSON-Decoded PHP-Array)
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>Table: cities
  ---------------
  id          int
  name        string
  
  Table: districts
  ---------------
  id          int
  city_id     int     FK to Table cities
  name        string
  </code></pre>
  
  <p>This is just a simple example, but there can be much more complex structures, like:</p>
  
  <pre><code>Table: cities
  ---------------
  id          int
  name        string
  data        string (JSON-Decoded PHP-Array)
  
  // Where data is a json-decoded PHP-Array like this:
  $city_1["data"] = array(
      "districts"     =&gt; array( 1 =&gt; "East District", 2 =&gt; "West District"),
      "special_text1" =&gt; "This text exists only in 10% of the cities",
      "special_text2" =&gt; "This text exists only in 1% of the cities"
  );
  $city_2["data"] = array(
      "districts"     =&gt; array( 1 =&gt; "South District", 2 =&gt; "West District", 3 =&gt; "Northern"),
      "special_text1" =&gt; "This text exists only in 10% of the cities",
  );
  </code></pre>
  
  <p>So my question is: Is there a problem using json-decoded fields, for example because of performace, etc?</p>