title: Maintain unique id across multiple tables
body: <p>I want to build a database-wide unique id.  That unique id should be one field of every row in every table of that database.</p>
  
  <p>There are a few approaches I have considered:</p>
  
  <ul>
  <li><p>Create one master-table with an auto-increment-field and a trigger in every other table, like:</p>
  
  <p>"before insert here, insert in master-table -> get the auto-increment value -> and use this value as primary-key here"</p>
  
  <p>I have seen this before, but instead of making one INSERT, it does 2 INSERTS, which I expect would not be that performant.</p></li>
  <li><p>Add a field <code>uniqueId</code> to every table, and fill this field with a PHP-generated integer... something like unix-timestamp plus a random number.</p>
  
  <p>But I had to use <code>BIGINT</code> as the datatype, which means big <code>index_length</code> and big <code>data_length</code>.</p></li>
  <li><p>Similar to the "uniqueId" idea, but instad of <code>BIGINT</code> I use <code>VARCHAR</code> and use <code>uniqid()</code> to populate this value.</p></li>
  </ul>