mardi 29 octobre 2019

Business layer to handle broken database relationship

There are database tables which store the copies of data and unfortunately the original author of these tables didn't design in using relationship (FK, Guid, etc.) in referring to the data when needed but actually copied over data themselves to other tables.. maybe that was for reducing overhead and making easier to retrieve all necessary information in one query.

And now there comes issues obviously because another person wrote code such, let's say 'data 1' in 'table A' can be modified by user, when that 'data 1' is also in 'table B' and 'table C'. At least it's not totally hopeless because there is another column in 'table A', let's say 'key 1', that can be used paired with 'data 1' when copied over to 'table B' and 'table C' so at least the relationship is not lost when changed by user.

Currently the code uses asp.net MVC pattern and I understand that the fix is probably depending on how code is written and all that, however does anyone know well known fix for issue like this? Design pattern, architecture, etc. Right now redesigning database schema is not an option and needs to be backward compatible, meaning should be able to handle old formats without keys, but the plan is updating already stored data to have keys eventually.

Aucun commentaire:

Enregistrer un commentaire