The Best Way To Add Audit Tables to Your Database

preview_player
Показать описание

Creating audit tables in your database will allow you to keep a history of changes made to data. This is helpful for regulatory and audit purposes, but it's also good if you have general business requirements to capture and show a history of changes.

In this video, you'll see three different options for creating audit tables in your database, and the option I recommend.

⏱ TIMESTAMPS:
00:00 - Option 1
03:01 - Option 2
05:11 - Option 3
07:36 - My recommendation
Рекомендации по теме
Комментарии
Автор

Hi, I am working as SQL developer, recently we completed data model for one project, In which we go with option 1 for audit log. We discussed both options 1 and 2, but finalise same table for audit log as there won't be lots of data that may cause performance issue. Btw cheers for your efforts, love your videos 😊

dhruvitmodi
Автор

A better approach IMO to option 2 or 3 is to serialize the original row into a XML or JSON into the general audit table. This way is flexible enough to handle any source table structure and you don't need multiple rows to save every field that changed. Just my 2 cents.

SerenityMusicOasis
Автор

How about inserting deleting and updating the original table and at the same time record each change of state in the separate audit table and for fetching the records we can use orignal table only

Yalchin
Автор

If the "ROW_KEY" is a randomly assigned key value by the database that can change at a later time, why would you audit the "ROW_KEY"?

kodekorp
Автор

is Option 2 the same thing as Temporal Tables in SQL Server and if so do you recommend using them?

RiGoRmOrTiSUK
Автор

Hi, your videos are so helpful, I have a question, I'm working on a CMS, The CMS has two separate sites, a public site and an admin panel, should I have 2x tables, tblUser for Public site login and tblAdminUsers for Admin site login or just one table tblUsers two store both users?

I’m aware I can apply roles to each user and based on roles I can manage logins but Admin user will have only few columns of information on the other hand the public users will have a lot of columns, so if I make one table for both users, many columns will have null values for Admin Users…
What would you do in such scenarios?

ALEGIONS
Автор

What do you think of this option ?

Products:

Pk Id
Username
CurrentVersion
IsActive


ProductVersions:

PK FK ProductId
PK Version
Name
Description
Price
DateTimeAdded

mariewebb