Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimary keys, UUIDs, RecordKey tables, oh my
    primarykey
    data
    text
    <p>While working on a content management system, I've hit a bit of a wall. Coming back to my data model, I've noticed some issues that could become more prevalent with time.</p> <p>Namely, I want to maintain a audit trail (change log) of record modification by user (even user record modifications would be logged). Due to the inclusion of an arbitrary number of modules, I cannot use a by-table auto incrementation field for my primary keys, as it will inevitably cause conflicts while attempting to maintain their keys in a single table.</p> <p>The audit trail would keep records of <code>user_id</code>, <code>record_id</code>, <code>timestamp</code>, <code>action</code> (INSERT/UPDATE/DELETE), and <code>archive</code> (a serialized copy of the old record)</p> <p>I've considered a few possible solutions to the issue, such as generating a <code>UUID</code> primary key in application logic (to ensure cross database platform compatibility).</p> <p>Another option I've considered (and I'm sure the consensus will be negative for even considering this method) is, creating a <code>RecordKey</code> table, to maintain a globally auto-incremented key. However, I'm sure there are far better methods to achieve this.</p> <p>Ultimately, I'm curious to know of what options I should consider in attempting to implement this. For example, I intend on permitting (to start at least) options for MySQL and SQLite3 storage, but I'm concerned about how each database would handle <code>UUID</code>s.</p> <p>Edit to make my question less vague: <strong>Would using global IDs be a recommended solution for my problem? If so, using a 128 bit UUID (application or database generated) what can I do in my table design that would help maximize query efficiency?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload