hi all, i'm trying to set up a system where data isnt deleted in certain tables in the database (i know.. visions of lotus notes are popping through your heads ... )
here's an example of why:
tblUsers (userID, firstname, lastname, DOB, username, password, enabled, dteModified)
i'd like to set a trigger up so that whenever an update statement is run against the table, rather than have it update the data, it inserts a new record with 'updated' data, and disabled the old record.
this works well for things like password uniqueness tracking.. because i'll have a simple lookup of all that users changes to check against.
my other option was to create a seperate table that stores every password and relates back to the user that used it. but that then requires new modules of code to be written, and, what happens when we decide that now other information about the user needs to be kept track of... new tables? bad idea...
similarly if the user is constantly changing their other information for example address details, i need to always know what the address was at the time that information was used.
the best i can work out is a change like this (assuming that i can find out the command to stop the update in the update trigger):
tblUsers (userID, userUID, firstname, lastname, DOB, username, password, enabled, dteModified)
where userID is the ID refrenced by all other tables that dont care about the user information at the time, and userUID is the ID refrenced by tables that do.
now, when establishing the primary key for this i'm running into trouble because i need both fileds as a composite key. but when i do that, i'm forced in every related table to have userID and userUID in there. technically this doesnt stop me from doing what i want, but it does add an element of 'usless' data to my database that i'm trying to avoid.
any thoughts or suggestions on this?
thanks!
-Chris
here's an example of why:
tblUsers (userID, firstname, lastname, DOB, username, password, enabled, dteModified)
i'd like to set a trigger up so that whenever an update statement is run against the table, rather than have it update the data, it inserts a new record with 'updated' data, and disabled the old record.
this works well for things like password uniqueness tracking.. because i'll have a simple lookup of all that users changes to check against.
my other option was to create a seperate table that stores every password and relates back to the user that used it. but that then requires new modules of code to be written, and, what happens when we decide that now other information about the user needs to be kept track of... new tables? bad idea...
similarly if the user is constantly changing their other information for example address details, i need to always know what the address was at the time that information was used.
the best i can work out is a change like this (assuming that i can find out the command to stop the update in the update trigger):
tblUsers (userID, userUID, firstname, lastname, DOB, username, password, enabled, dteModified)
where userID is the ID refrenced by all other tables that dont care about the user information at the time, and userUID is the ID refrenced by tables that do.
now, when establishing the primary key for this i'm running into trouble because i need both fileds as a composite key. but when i do that, i'm forced in every related table to have userID and userUID in there. technically this doesnt stop me from doing what i want, but it does add an element of 'usless' data to my database that i'm trying to avoid.
any thoughts or suggestions on this?
thanks!
-Chris