title: Cannot add or update a child row: a foreign key constraint fails
body: <p>table #1:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Field</th>
  <th>Type</th>
  <th>Null</th>
  <th>Key</th>
  <th>Default</th>
  <th>Extra</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>UserID</td>
  <td>int(11)</td>
  <td>NO</td>
  <td>PRI</td>
  <td>NULL</td>
  <td>auto_increment</td>
  </tr>
  <tr>
  <td>Password</td>
  <td>varchar(20)</td>
  <td>NO</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Username</td>
  <td>varchar(25)</td>
  <td>NO</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Email</td>
  <td>varchar(60)</td>
  <td>NO</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>table #2:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Field</th>
  <th>Type</th>
  <th>Null</th>
  <th>Key</th>
  <th>Default</th>
  <th>Extra</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>UserID</td>
  <td>int(11)</td>
  <td>NO</td>
  <td>MUL</td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>PostID</td>
  <td>int(11)</td>
  <td>NO</td>
  <td>PRI</td>
  <td>NULL</td>
  <td>auto_increment</td>
  </tr>
  <tr>
  <td>Title</td>
  <td>varchar(50)</td>
  <td>NO</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Summary</td>
  <td>varchar(500)</td>
  <td>NO</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Error:</p>
  <blockquote>
  <p>com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
  Cannot add or update a child row: a foreign key constraint fails
  (<code>myapp/table2</code>, CONSTRAINT <code>table2_ibfk_1</code> FOREIGN KEY (<code>UserID</code>)
  REFERENCES <code>table1</code> (<code>UserID</code>))</p>
  </blockquote>
  <p>What have I done wrong? I read <a href="http://www.w3schools.com/Sql/sql_foreignkey.asp" rel="noreferrer">http://www.w3schools.com/Sql/sql_foreignkey.asp</a> and I don't see what's wrong.</p>