Change data, only for the new data onward

Hi there, I have an app with users (Name, email, etc) and user history for checking in.

What I wanna do is, I want to change the name of the user from Alex to Andy, but do not want the history data of Alex to be changed to Andy.

What really happened is user Alex resigned and then the same email (corporate email) is reused for user Andy. 

Solved Solved
0 3 56
1 ACCEPTED SOLUTION

Hello @Rome18 

I believe this is a DB design issue.

What is the key of the users? 

How are the log in histories captures?

Let's say your users table is

Users

email: key

name

etc

Logs

log id: arbitrary key such as UNIQUEID()

email: 

name: this is copied from the user table at the time of each logon but never modified, meaning the name in your log table does not change even if it changes in the users table

logon date:

This way you should be able to report what name was used when based on the logs.

 

Another option might be to maintain a User history table to capture email - name pair over a period of time.

But this would be a bit more complicated.

 

View solution in original post

3 REPLIES 3

Hello @Rome18 

I believe this is a DB design issue.

What is the key of the users? 

How are the log in histories captures?

Let's say your users table is

Users

email: key

name

etc

Logs

log id: arbitrary key such as UNIQUEID()

email: 

name: this is copied from the user table at the time of each logon but never modified, meaning the name in your log table does not change even if it changes in the users table

logon date:

This way you should be able to report what name was used when based on the logs.

 

Another option might be to maintain a User history table to capture email - name pair over a period of time.

But this would be a bit more complicated.

 

I see, so I need to make the email the key right?

What I did before is I have users ID as the key of my users table and ref it up on the logs

User id as your USERS table key also works.

The point is you log the name of the user in your logs and just do not change it.

Top Labels in this Space