title: SQL Foreign Key before commit
body: <p>In a game server code in Java, I split the client data into many tables, to ease adding new content in the future. </p>
  
  <p>Right now I have the following tables </p>
  
  <ul>
  <li>names</li>
  <li>auth</li>
  <li>inventory</li>
  </ul>
  
  <p>The <code>name</code> table contains the columns <code>id</code> and <code>name</code>.</p>
  
  <p>The <code>auth</code> table has columns <code>id</code> and <code>password</code>. </p>
  
  <p>The <code>id</code> column on the <code>auth</code> and <code>inventory</code> tables have foreign key constraints on the <code>name</code>'s <code>id</code> column. </p>
  
  <p>When creating a new client, I insert into the <code>name</code> table, get the generated id and insert the rest of the data in the other tables in separate insert statements, but all in a single transaction. </p>
  
  <p>The problem is, when I insert into the <code>auth</code> table, it fails because of the foreign key check in <code>name</code> because I haven't commited it yet. Is there a better way to solve this without commiting on every insert?</p>