Как управлять версией записей со ссылками на записи (внешние ключи)
I am developing an application and in which i have multiple tables, Table Name : User_master |Id (PK,AI) | Name | Email | Phone | Address Table Name: User_auth |Id (PK,AI) | user_id(FK_userMaster) | UserName | password | Active_Status Table Name: Userbanking_details |Id (PK,AI) | user_id(FK_userMaster) | Bank Name | account Name | IFSC Now, what i want is to save all the updates done in records should not be updated directly instead it should control the version that means i want to track the log of all previous updates user has done. which means if user updates the address, then also previous address record history should be stored into the table. How can i achieve this?
Что я уже пробовал:
I have tried it by adding fields version_name,version_latest,updated_version_of field and insert new record when update like |Id (PK,AI) | Name | Email | Phone | Address |version_name |version_latest| updated_version_of 1 | ABC |ABC@gm.com|741852|LA |1 |0 |1 2 | ABC |ABC@gm.com|852741|NY |2 |1 |1 Now the problem comes here is the user table is in FK with other two listed tables so when updating the record their relationship will be lost because of new ID. I want to preserve the old data shown as old and new updated records will be in effect only with new transactions.
Santosh kumar Pithani
Здравствуйте, я надеюсь, что эта проблема будет преодолена с помощью ссылки на внешний ключ "on update cascade", а также написать одну хранимую процедуру для обновления старого значения в другой столбец.