Search code examples
mysqldatabase-designnormalizationdatabase-relations

Restructure tables on an existing website, to store historical data?


I've been trying to find a match for my issue in existing questions, and I'll accept links as an answer and close my question if you have them.

What I'm trying to find is a way to restructure my existing tables. I have a website, and I spent kind of a long time working on it. Now I have all the tables and selects in place. Unfortunately, the "First Name" "Last Name" table is changing a lot, as users update their info. I want to store historical data for these fields, so I can find users by their real names after they've changed them. The names aren't unique, but they're easier to remember than their ID numbers. So, I have a member's table with the fields (username, email, firstname, middlename, familyname, dob, password, country). Should I just create new tables for firstname and familyname so that I can store the changes?


Solution

  • I had a similar problem. I got out of the situation so Created a table with this kind of fields.

    | Id | id_user | name_field | value | date |
    

    I think a lot of clear ... "name_field" is that the user has changed ... (Name, Country, etc.) "value" that was in the cell and the "date" when there was a change