title: How to structure a database with two connected tables?
body: <p>I have a MySQL database with one table that has the following stricture below. I also have a single-field table <code>users</code> that are just unique ids of type long. <em>We can perhaps think of them as a separate table <code>users</code> with just the field <code>id</code> and no other information at this point.</em></p>
  <p><em>So now to the question:</em>
  My goal is to make it so that when a user selects a city they could increment its <code>vote</code> value by one only once. They should be able to vote on multiple cities but they should only be able to increment a <code>vote</code> value for a given city only once.
  <em><strong>What is the smart way (optimise time) of doing this using only MySQL (and JAVA)?</strong></em></p>
  <p><em>I am not looking for a complete solution but rather the way you should think here since I am new to databases.</em> <em>Like, is the optimal way (if we optimise for time) of creating same number of fields as there are cities for each user and maybe putting a true false value there and then if the user tries to vote for the city one more time we could just check if that field is true or false for that specific user id?</em></p>
  <pre><code>+----+------+--------+-----------+
  | id | city | vote   | comment   |
  +----+------+--------+-----------+
  |  1 | NY   |      1 | Something |
  |  2 | W    |      2 | NULL      |
  |  3 | C    |      6 | Something |
  |  4 | LA   |      1 | NULL      |
  +----+------+--------+-----------+
  </code></pre>