Skip to content

Instantly share code, notes, and snippets.

@sam0x17
Last active January 24, 2017 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam0x17/8d787bc5a1345c6629578cbfd9f77b16 to your computer and use it in GitHub Desktop.
Save sam0x17/8d787bc5a1345c6629578cbfd9f77b16 to your computer and use it in GitHub Desktop.
ancestor UUID's

A UUID is a globally unique universal identifier. These are extremely useful in a CRM-like environment, because they can express descendant/ancestor relationships without the need to traverse a join chain of intermediate relationships. You can get everything "belonging" to a particular user/record/account/whatever in a single SELECT statement with no JOINS.

for every row in the database across ALL tables:

  • assign a database-wide unique UUID record.uuid
  • the first two digits of the UUID identify the table to which the record belongs
  • add an array field called ancestor_uuids containing the UUIDs of all ancestor records (up to Account)

so a Task record might have UUIDs for a RepeatingTask, User, and Account in its ancestor_uuids array

Now what can we do with this? *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment