sys_audit_relation table purpose?

dwblack
ServiceNow Employee
ServiceNow Employee

Hi,

I'm looking to track CI relationship changes (CI-CI and CI-Task-based elements) and wondering what the role of the SYS_AUDIT_RELATION table is.     Removing a CI-CI relation logs entries in here but adding a relationship doesn't.       It's obviously related to the SYS_AUDIT and SYS_AUDIT_DELETE tables but I can't work out it's purpose for or the events relating to enties.

Anyone help me out?

cheers
Dave

2 REPLIES 2

Daniel Pettet
ServiceNow Employee
ServiceNow Employee

sys_audit_relation = "Audit Relationship Change"



I believe that the sys_audit_relation table tracks changes to reference fields (sys_ids).


Per record there is a document key and table ( = context), "Audit" and "Audit Delete" fields.



"Audit Delete" -> Reference to sys_audit_delete (records that have been deleted).



"Audit" -> Reference to sys_audit table (all changes).


All these sys_audit references listed in the sys_audit_relation table have sys_id values for "old" and/or "new" values. Therefore, the sys_audit_relation focus on tracking sys_id changes throughout the system and utilises sys_audit and sys_audit_delete tables to do so. It is most likely a kind of caching or "quick reference" table used by the system.


Amit Pattnaik
Tera Contributor

The Sys Audit [sys_audit] table tracks activity in tables that are flagged for auditing. This activity includes journal field entries and history sets. The Audit Relationship Change [sys_audit_relation] table tracks relationship changes between sys_audit table records and the source tables that the audited records originate from. It also tracks when a record might have been deleted.

  • Whenever you audit any record in a table, a relationship is created between the various originating tables to the store that records data. This relationship information is saved in the sys_history_set, sys_history_line, and sys_journal tables.
  • If you delete a field that is related to an audited table record, the sys_audit_relation table records the deletion. In other words, anytime you change an audited record, it first deletes past elements, and then creates a relationship in the sys_audit_relation table with new document IDs.