Use Auto incremented unique id primary key as foreign key in another table
<p>I have a table <code>primary_details</code> which has the the following fields</p>

<p><code>uid</code> ---> primary key &amp; Auto incremented &amp; unique <br>
<code>name</code><br>
<code>age</code></p>

<p>I have another table <code>cust_info</code> with the following fields</p>

<p><code>uid</code> ---> foreign key of primary key in <code>primary_details</code> table &amp; not unique <br>
<code>score</code><br>
<code>comments</code></p>

<p>Now the question is when ever I insert a row in <code>primary_details</code> table it automatically inserts the value in <code>uid</code> column and it auto increments on all subsequent new rows which is perfect. However now I want the <code>uid</code> in <code>cust_info</code> table to also have the same <code>uid</code> value as in the <code>primary_details</code> table when ever I write a row in the <code>primary_details</code> table</p>

<p>For Eg: </p>

<p>In <code>primary_details</code> table if I insert the following row</p>

<pre><code>uid    name   age   
1      Mark   25
</code></pre>

<p>Now if I insert a record in secondary table right after the above one it should also get the <code>uid</code> 1</p>

<p>I'm using Java to write the tables. In java I can easily generate a <code>uid</code> and insert it into the table but I wanna use the unique ID and auto increment feature in MySQL</p>