I want to be able to log who did what on which table. I need to display this information on the web application. Is there an easy way of doing this, rather that making duplicates of a lot of data?
The best way I have thought of so far is making a new table with the following fields:
Table_Changed
Table_Primary_Key
Old_Field_Value
New_Field_Value
User
Date_Changed
Every time someone changes something, it is logged in this table, so that, at any time, I can display who changed what.
I have one more question. If I do do it this way, is there a way of getting the primary key value of any table? E.G. could I do something like this_table.primary_key.value ?
JagsYou may try to use "Trigger" to do this.|||Thank you for the help, but I am not actually worried about how I am going to do it (I was thinking of using triggers anyway).
I am more worried about whether the method I am using will work nicely, or will the table I create become so large that it will slow the server down too much.|||I guess how large the table gets will depend on how many updates your site will do each day. One option to get around this is to archive the data at set intervals. For instance, setup a sql server job once a month to copy all the data from the production server's logging table onto a 2nd servers logging table. This table would reside on a server that doesn't matter as much how fast it is running as the backup would happen in the middle of the night or some other time of inactivity.
No comments:
Post a Comment