sql server - Audit table woes -
i trying make audit table records pretty in system. going use triggers, want record things searches, etc , want record action-er (the user performed action).
so, because there many different objects in application need recording (profiles, companies, pages, etc) needed create table hold information different objects.
i using mssql perhaps should have looked @ document database not sure whether using sql database data , document database audits idea....maybe has experience this?
anyway, table looks this:
create table [dbo].[cg_audittrail]( [id] [int] identity(1,1) not null, [companyid] [uniqueidentifier] not null, [userid] [uniqueidentifier] not null, [username] [nvarchar](255) not null, [objectname] [nvarchar](100) not null, [eventid] [int] not null, [data] [xml] not null, [date] [datetime] not null, constraint [pk_cg_audittrail] primary key clustered ( [id] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] go alter table [dbo].[cg_audittrail] check add constraint [fk_cg_audittrail_cg_auditeventtypes] foreign key([eventid]) references [dbo].[cg_auditeventtypes] ([id]) go alter table [dbo].[cg_audittrail] check constraint [fk_cg_audittrail_cg_auditeventtypes] go
as can see storing object xml in database. have created factory class in project convert of objects serializable objects. part isn't necessary objects is. here example 1 of factory objects:
public static objects.page pagefactory(page object) { objects.page factoryobject = new objects.page() { id = object.id, parentid = object.parentid, userid = object.userid, companyid = object.companyid, author = object.author, datecreated = object.datecreated, datemodified = object.datemodified, modifiedbyid = object.modifiedbyid, modifiedby = object.modifiedby, name = object.name, description = object.description, path = object.path, filename = object.filename, link = object.link, viewtitle = object.viewtitle, restricted = object.restricted, published = object.published, typeid = object.typeid, type = object.type.tostring(), order = object.order, }; return factoryobject; }
so questions follows:
- is way create audit?
- if want data our of xml column, possible in sql?
- would better using document database instead of mssql?
any appreciated, /r3plica
Comments
Post a Comment