Skip to content

Instantly share code, notes, and snippets.

@LordSputnik
Last active December 15, 2015 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LordSputnik/af00aa89642387b39e13 to your computer and use it in GitHub Desktop.
Save LordSputnik/af00aa89642387b39e13 to your computer and use it in GitHub Desktop.
How to do various things in the new schema

Using the "schema" of:

http://yuml.me/edit/86aaba0d

Entity

Creating an Entity

  1. Insert row into entity table ()
  2. Insert row into revision table ()
  3. Insert row into <entity>_data table (...data)
  4. Insert row into <entity>_header table (bbid)
  5. Insert row into <entity>_revision table (revision_id, bbid, data_id)

Updating an Entity

  1. Insert row into revision table ()
  2. Duplicate existing row in <entity>_data table, updating (...data)
  3. Insert row into <entity>_revision table (revision_id, bbid, data_id)

Merging Entities

  1. Insert row into revision table ()
  2. Duplicate target entity data row in <entity>_data table (...data)
  3. Bulk-add aliases from user-selected source entity data which don't already exist on target data using procedure for "Adding an Alias"
  4. Bulk-add identifiers from user-selected source entity data which don't already exist on target data using procedure for "Adding an Identifier"
  5. Bulk-add relationships from user-selected source entity data which don't already exist on target data using procedure for "Adding a Relationship"

Deleting an Entity

  1. Insert row into revision table ()
  2. Insert row into <entity>_revision table (revision_id, bbid, null)

Aliases(/Identifiers)

Adding an Alias(/Identifier)

  1. Insert row into alias_set
  2. Insert rows into alias_set__alias for existing aliases
  3. Insert row into alias
  4. Insert row into alias_set__alias for new alias
  5. Duplicate existing row in <entity>_data table, updating (alias_set_id)
  6. Insert row into revision table ()
  7. Insert row into <entity>_revision table (revision_id, bbid, data_id)

Editing an Alias(/Identifier)

  1. Insert row into alias_set
  2. Insert rows into alias_set__alias for existing aliases, apart from updated
  3. Duplicate alias row, edit required fields
  4. Insert row into alias_set__alias for updated alias
  5. Duplicate existing row in <entity>_data table, updating (alias_set_id)
  6. Insert row into revision table ()
  7. Insert row into <entity>_revision table (revision_id, bbid, data_id)

Deleting an Alias(/Identifier)

  1. Insert row into alias_set
  2. Insert rows into alias_set__alias for existing aliases, apart from deleted
  3. Duplicate existing row in <entity>_data table, updating (alias_set_id)
  4. Insert row into revision table ()
  5. Insert row into <entity>_revision table (revision_id, bbid, data_id)

Relationships

Creating a Relationship

  1. Insert two rows into relationship_set ()
  2. Insert two rows into relationship_set__relationship for each existing relationship (set_id, relationship_id, source)
  3. Insert a row into relationship (type_id)
  4. Insert two rows into relationship_set__relationship for the new relationship (set_id, relationship_id, source)
  5. Insert row into revision table ()
  6. Duplicate existing rows in <entity>_data tables, updating (...relationship_set)
  7. Insert rows into <entity>_revision tables (revision_id, bbid, data_id)
  8. Insert two rows into revision_parent - one for each parent revision, linking to the newly created revision

Updating a Relationship

  1. Insert two rows into relationship_set ()
  2. Insert two rows into relationship_set__relationship for each existing relationship, apart from updated (set_id, relationship_id, source)
  3. Duplicate row in relationship to be edited, updating with new type (type_id)
  4. Insert two rows into relationship_set__relationship for the updated relationship (set_id, relationship_id, source)
  5. Insert row into revision table ()
  6. Duplicate existing rows in <entity>_data tables, updating (...relationship_set)
  7. Insert rows into <entity>_revision tables (revision_id, bbid, data_id)
  8. Insert two rows into revision_parent - one for each parent revision, linking to the newly created revision

Deleting a Relationship

  1. Insert two rows into relationship_set ()
  2. Insert two rows into relationship_set__relationship for each existing relationship, apart from deleted (set_id, relationship_id, source)
  3. Insert row into revision table ()
  4. Duplicate existing rows in <entity>_data tables, updating (...relationship_set)
  5. Insert rows into <entity>_revision tables (revision_id, bbid, data_id)
  6. Insert two rows into revision_parent - one for each parent revision, linking to the newly created revision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment