Tables [dbo].[arg_rel_governing_document]
Properties
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
Row Count2
Created10:33:15 PM Thursday, February 10, 2011
Last Modified5:14:30 PM Tuesday, April 26, 2011
Columns
NameData TypeMax Length (Bytes)Allow NullsDefault
Cluster Primary Key pkrel_governing_document: relationship_idrelationship_idbigint8
No
Foreign Keys GOV_DOC_LEGALDOC_FK01: [dbo].[arg_legaldoc].object_uuidIndexes rel_governing_document_idx01: object_uuid\secondary_object_uuidobject_uuidbinary(16)16
No
ac1ividint4
Yes
acdatedtdatetime8
Yes
actimetmnvarchar(8)16
Yes
accommntnvarchar(255)510
Yes
actext1nvarchar(30)60
Yes
acint1int4
Yes
acdate1datetime8
Yes
Foreign Keys GOV_DOC_LEGALDOC_FK02: [dbo].[arg_legaldoc].secondary_object_uuidIndexes rel_governing_document_idx01: object_uuid\secondary_object_uuidsecondary_object_uuidbinary(16)16
No
lk2ividint4
Yes
lkinstncint4
Yes
lkstrtdtdatetime8
Yes
lkenddtdatetime8
Yes
lkcommntnvarchar(255)510
Yes
creation_usernvarchar(64)128
Yes
creation_dateint4
Yes
last_update_usernvarchar(64)128
Yes
last_update_dateint4
Yes
version_numberint4
Yes
('0')
inactiveint4
No
('0 ')
Foreign Keys FK_GOVERNING_DOCUMENT_TENANT: [dbo].[ca_tenant].tenanttenantbinary(16)16
Yes
Indexes Indexes
NameColumnsUnique
Cluster Primary Key pkrel_governing_document: relationship_idpkrel_governing_documentrelationship_id
Yes
rel_governing_document_idx01object_uuid, secondary_object_uuid
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
ca_tr_del_arg_rel_governing_do
Yes
Yes
After Delete
ca_tr_ins_arg_rel_governing_do
Yes
Yes
After Insert
ca_tr_upd_arg_rel_governing_do
Yes
Yes
After Update
Foreign Keys Foreign Keys
NameColumns
FK_GOVERNING_DOCUMENT_TENANTtenant->[dbo].[ca_tenant].[id]
GOV_DOC_LEGALDOC_FK01object_uuid->[dbo].[arg_legaldoc].[legaldoc_uuid]
GOV_DOC_LEGALDOC_FK02secondary_object_uuid->[dbo].[arg_legaldoc].[legaldoc_uuid]
SQL Script
CREATE TABLE [dbo].[arg_rel_governing_document]
(
[relationship_id] [bigint] NOT NULL,
[object_uuid] [binary] (16) NOT NULL,
[ac1ivid] [int] NULL,
[acdatedt] [datetime] NULL,
[actimetm] [nvarchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[accommnt] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[actext1] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[acint1] [int] NULL,
[acdate1] [datetime] NULL,
[secondary_object_uuid] [binary] (16) NOT NULL,
[lk2ivid] [int] NULL,
[lkinstnc] [int] NULL,
[lkstrtdt] [datetime] NULL,
[lkenddt] [datetime] NULL,
[lkcommnt] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[creation_user] [nvarchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[creation_date] [int] NULL,
[last_update_user] [nvarchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[last_update_date] [int] NULL,
[version_number] [int] NULL CONSTRAINT [DF__ARG_REL_G__VERSI__3DE82FB7] DEFAULT ('0'),
[inactive] [int] NOT NULL CONSTRAINT [DF__ARG_REL_G__INACT__3EDC53F0] DEFAULT ('0 '),
[tenant] [binary] (16) NULL
) ON [PRIMARY]

GO
CREATE TRIGGER dbo.ca_tr_del_arg_rel_governing_do
ON dbo.arg_rel_governing_document
FOR DELETE AS
DECLARE
        @audit_product nvarchar(64)
        SET @audit_product = APP_NAME()
INSERT INTO dbo.aud_arg_rel_governing_document (
AUDIT_TRAIL_PRODUCT,
AUDIT_TRAIL_USER,
AUDIT_TRAIL_TYPE,
AUDIT_TRAIL_DATE,
relationship_id,
object_uuid,
ac1ivid,
acdatedt,
actimetm,
accommnt,
actext1,
acint1,
acdate1,
secondary_object_uuid,
lk2ivid,
lkinstnc,
lkstrtdt,
lkenddt,
lkcommnt,
creation_user,
creation_date,
last_update_user,
last_update_date,
version_number,
inactive,
tenant) SELECT

@audit_product,old.last_update_user, 'DELETE', datediff(ss, '1/1/1970', getutcdate()),
old.relationship_id,
old.object_uuid,
old.ac1ivid,
old.acdatedt,
old.actimetm,
old.accommnt,
old.actext1,
old.acint1,
old.acdate1,
old.secondary_object_uuid,
old.lk2ivid,
old.lkinstnc,
old.lkstrtdt,
old.lkenddt,
old.lkcommnt,
old.creation_user,
old.creation_date,
old.last_update_user,
old.last_update_date,
old.version_number,
old.inactive,
old.tenant
FROM deleted old
GO
CREATE TRIGGER dbo.ca_tr_ins_arg_rel_governing_do
ON dbo.arg_rel_governing_document
FOR INSERT AS
DECLARE
        @audit_product nvarchar(64)
        SET @audit_product = APP_NAME()
INSERT INTO dbo.aud_arg_rel_governing_document (
AUDIT_TRAIL_PRODUCT,
AUDIT_TRAIL_USER,
AUDIT_TRAIL_TYPE,
AUDIT_TRAIL_DATE,
relationship_id,
object_uuid,
ac1ivid,
acdatedt,
actimetm,
accommnt,
actext1,
acint1,
acdate1,
secondary_object_uuid,
lk2ivid,
lkinstnc,
lkstrtdt,
lkenddt,
lkcommnt,
creation_user,
creation_date,
last_update_user,
last_update_date,
version_number,
inactive,
tenant) SELECT

@audit_product, new.last_update_user, 'INSERT', datediff(ss, '1/1/1970', getutcdate()),
new.relationship_id,
new.object_uuid,
new.ac1ivid,
new.acdatedt,
new.actimetm,
new.accommnt,
new.actext1,
new.acint1,
new.acdate1,
new.secondary_object_uuid,
new.lk2ivid,
new.lkinstnc,
new.lkstrtdt,
new.lkenddt,
new.lkcommnt,
new.creation_user,
new.creation_date,
new.last_update_user,
new.last_update_date,
new.version_number,
new.inactive,
new.tenant
FROM inserted new
GO
CREATE TRIGGER dbo.ca_tr_upd_arg_rel_governing_do
ON dbo.arg_rel_governing_document
FOR UPDATE AS
DECLARE
        @audit_product nvarchar(64),
        @last_update_user nvarchar(64),
        @version_number int


        SET @audit_product = APP_NAME()
SELECT  @version_number = version_number, @last_update_user = last_update_user FROM inserted

IF @version_number != -1
INSERT INTO dbo.aud_arg_rel_governing_document (
AUDIT_TRAIL_PRODUCT,
AUDIT_TRAIL_USER,
AUDIT_TRAIL_TYPE,
AUDIT_TRAIL_DATE,
relationship_id,
object_uuid,
ac1ivid,
acdatedt,
actimetm,
accommnt,
actext1,
acint1,
acdate1,
secondary_object_uuid,
lk2ivid,
lkinstnc,
lkstrtdt,
lkenddt,
lkcommnt,
creation_user,
creation_date,
last_update_user,
last_update_date,
version_number,
inactive,
tenant) SELECT

@audit_product, new.last_update_user, 'UPDATE', datediff(ss, '1/1/1970', getutcdate()),
new.relationship_id,
new.object_uuid,
new.ac1ivid,
new.acdatedt,
new.actimetm,
new.accommnt,
new.actext1,
new.acint1,
new.acdate1,
new.secondary_object_uuid,
new.lk2ivid,
new.lkinstnc,
new.lkstrtdt,
new.lkenddt,
new.lkcommnt,
new.creation_user,
new.creation_date,
new.last_update_user,
new.last_update_date,
new.version_number,
new.inactive,
new.tenant
  FROM inserted new
GO
ALTER TABLE [dbo].[arg_rel_governing_document] ADD CONSTRAINT [pkrel_governing_document] PRIMARY KEY CLUSTERED ([relationship_id]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [rel_governing_document_idx01] ON [dbo].[arg_rel_governing_document] ([object_uuid], [secondary_object_uuid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[arg_rel_governing_document] ADD CONSTRAINT [FK_GOVERNING_DOCUMENT_TENANT] FOREIGN KEY ([tenant]) REFERENCES [dbo].[ca_tenant] ([id])
GO
ALTER TABLE [dbo].[arg_rel_governing_document] ADD CONSTRAINT [GOV_DOC_LEGALDOC_FK01] FOREIGN KEY ([object_uuid]) REFERENCES [dbo].[arg_legaldoc] ([legaldoc_uuid])
GO
ALTER TABLE [dbo].[arg_rel_governing_document] ADD CONSTRAINT [GOV_DOC_LEGALDOC_FK02] FOREIGN KEY ([secondary_object_uuid]) REFERENCES [dbo].[arg_legaldoc] ([legaldoc_uuid])
GO
Uses