![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi guys. On a previous project, the requirement was just to store who updated a row, and when. So, we have a: created_date, created_user_id, modified_date and modified_user_id However, phase 2 of this project - they want to know which fields in the row were edited by which user! So, basically, per field auditing. This is something I have never done. There's also two ways a field can be updated. It can be updated by a user, or via an automated process, at which point, a user should be stopped from editing it (client side enforcement). So, I was thinking that we could make a nullable field for the updated_user.. and if it's null, it was automated, and therefore locked... But.. this has to cover all the columns! It would be very messy to have, for example, a 'description' field, and then a 'description_modified_date', and 'description_modified_user_id'.... I was thinking maybe a separate table that covered all tables and columns that we need to log, and then a trigger to update these? But am not sure if this is a good move, or the most effective way of handling this requirement. When we display the screen, it would be a hefty procedure to populate the screen! We'd not only have to get the data, but then get all the audit data - so that we can show the developer if the user can edit the data or not. Headache! Unless there is a way that this is done previously? |
#3
| |||
| |||
|
|
On a previous project, the requirement was just to store who updated a row, and when. So, we have a: created_date, created_user_id, modified_date and modified_user_id However, phase 2 of this project - they want to know which fields in the row were edited by which user! So, basically, per field auditing. |
|
This is something I have never done. There's also two ways a field can be updated. It can be updated by a user, or via an automated process, at which point, a user should be stopped from editing it (client side enforcement). So, I was thinking that we could make a nullable field for the updated_user.. and if it's null, it was automated, and therefore locked... |
#4
| |||
| |||
|
|
Hi guys. On a previous project, the requirement was just to store who updated a row, and when. So, we have a: created_date, created_user_id, modified_date and modified_user_id However, phase 2 of this project - they want to know which fields in the row were edited by which user! So, basically, per field auditing. This is something I have never done. There's also two ways a field can be updated. It can be updated by a user, or via an automated process, at which point, a user should be stopped from editing it (client side enforcement). So, I was thinking that we could make a nullable field for the updated_user.. and if it's null, it was automated, and therefore locked... But.. this has to cover all the columns! It would be very messy to have, for example, a 'description' field, and then a 'description_modified_date', and 'description_modified_user_id'.... I was thinking maybe a separate table that covered all tables and columns that we need to log, and then a trigger to update these? But am not sure if this is a good move, or the most effective way of handling this requirement. When we display the screen, it would be a hefty procedure to populate the screen! We'd not only have to get the data, but then get all the audit data - so that we can show the developer if the user can edit the data or not. Headache! Unless there is a way that this is done previously? |
#5
| |||
| |||
|
|
Craig what versrion of SQL Server are *you using? |
#6
| |||
| |||
|
|
Hi guys. On a previous project, the requirement was just to store who updated a row, and when. So, we have a: created_date, created_user_id, modified_date and modified_user_id However, phase 2 of this project - they want to know which fields in the row were edited by which user! So, basically, per field auditing. This is something I have never done. There's also two ways a field can be updated. It can be updated by a user, or via an automated process, at which point, a user should be stopped from editing it (client side enforcement). So, I was thinking that we could make a nullable field for the updated_user.. and if it's null, it was automated, and therefore locked... But.. this has to cover all the columns! It would be very messy to have, for example, a 'description' field, and then a 'description_modified_date', and 'description_modified_user_id'.... I was thinking maybe a separate table that covered all tables and columns that we need to log, and then a trigger to update these? But am not sure if this is a good move, or the most effective way of handling this requirement. When we display the screen, it would be a hefty procedure to populate the screen! We'd not only have to get the data, but then get all the audit data - so that we can show the developer if the user can edit the data or not. Headache! Unless there is a way that this is done previously? |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
Issue with this is that this history table will grow a lot! For every update, there will be a new row. |
|
Also, it won't be very easy to query. |
|
That is, a business rule we have is that if a field was altered by an external source, then users can no longer edit it. it must be read- only. So, when we build the screen, it will be pretty inefficient for the database to work out who last changed which fields... |
![]() |
| Thread Tools | |
| Display Modes | |
| |