title: loading k:v pairs from DB into JS Object
body: <p>I'm creating a single player web RPG.</p>
  
  <p>I'm debating the following method of storing/retrieving quest items per player id:</p>
  
  <ul>
  <li>In <code>userstats</code> table, have a <code>quest_items</code> column of type <code>mediumtext</code>, where I would store the total amount of the item the player has as key, and item_name as value, like so:</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/fp6OT.png" alt="enter image description here"></p>
  
  <p>If I were to do it this way, how can I load that column data JSON into a JS object, where the key : value pairs are maintained, like so loaded for player "DAN":</p>
  
  <pre><code>quest_items = { 2 : "rice", 1 : "meat" };
  </code></pre>
  
  <hr>
  
  <ul>
  <li>Or, the alternative is to have some sort of association table, where I store the user_id against the item_id, maintaining single data in each column:</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/9VDLU.png" alt="enter image description here"></p>
  
  <p>The issue with this is, each time a user gained a quest item, I would have to update this table, which could be costly.</p>
  
  <hr>
  
  <p>Preferably, I would like to go with option 1, and </p>
  
  <ul>
  <li><p>when I need to update the quest_items in <code>userstats</code>, I simply pass in a js object with new data, JSON_encode it, and save it into the DB column as text.</p></li>
  <li><p>when I need to read it back out, just JSON_decode it</p></li>
  </ul>
  
  <p>Is it bad to store k:v pairs this way in a DB field?</p>