简体   繁体   中英

MS DateTime only LOG table

I am creating a database to store user information, and the changed made to the user will need to get logged.

This will eventually lead to a sort of 'timeline', so a Date / Time factor is crucial.

For this question, I will use the following example:

#ID - int
memName - string
memBio - string
memStatusString - string

Now, my though is to link that to a table as such:

ID - int
#memID - int
dateNameChanged - DateTime
dateBioChanged - DateTime
dateStatusStringChanged - DateTime

Is this a good way to log information? I want to do it on a different table to be easily able to list later.

Also, I never put the logging in the same table because the log date will only come after a change. IF the user never changes, it will just be a waste of space.

In conclusion;

Is there a better way to do this?

Update: I apologize for the lack of info. I am using SQL Server 2008, asp net c# 3.5 - 4 (Only doing the database structure atm).

Also, a member will have different tables, such as tblMemberInformation, tblClanInformation, tblMemberGameRank

Each of the CHANGED data (Just to confirm) in each of the tables will need to be stored to a log file, with the corresponding date.

You have not specified the version of SQL Server you are using, so I will assume a recent version.

SQL Server 2008+ has built in audit :

Auditing an instance of the SQL Server Database Engine or an individual database involves tracking and logging events that occur on the Database Engine. SQL Server audit lets you create server audits, which can contain server audit specifications for server level events, and database audit specifications for database level events. Audited events can be written to the event logs or to audit files.

SQL Audit does allow you to audit specific operations on specific objects. For instance you can audit just UPDATE on one single table. See http://www.ultimatewindowssecurity.com/sqlserver/auditpolicy/auditactiongroups/database-level_audit_actions.aspx . I realize SQL Audit may not fit this need but that is its capability.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM