title: Most efficient database schema for counting keywords
body: <p>I'm working on an iPhone app with a GAE backend. I currently have a database of ~8000 products and each product has 5 keywords, mined from reviews, that are the words used most often to describe the product. Once I deploy the app, I'd like to allow users to add new products, and add their 5 keywords to existing products. So, when "reviewing" an existing product, they would add their 5 words, and these would be reflected in the Top 5 words if they push a word over into the Top 5. These keywords will be selected via a large whitelist with indirect selection so I can control the user input. I'd like the application to scale to thousands of users without hitting my backend too hard.</p>
  
  <p>My question is: 
  What's the most efficient database schema for keeping track of all the words for a product and calculating the top 5 for each product once it's updated?</p>
  
  <p>My two ideas (which may be terrible): </p>
  
  <ol>
  <li><p>Have a "words" column which contains a 2d array, one dimension is the word, the other is the count for that word. They would then be incremented/decremented as needed.</p></li>
  <li><p>Have a database with each word as a column and each product as a row and the corresponding row/column would contain the count.</p></li>
  </ol>