Imagine this use case:
I have a class with 50 attributes of which 10 are relationships plus 100 methods which perform calculations and return a value.
I need to save that data (including relationships and method's return values) into a database for later retrieval. The idea is to have an snapshot of the current state of the object instance.
Currently I only need the data of 20 of that attributes and 25 method return values, but in the future will need to retrieve more. I will probably never use some of the data saved.
I could easily save and retrieve data from a JSON.
Now imagine that after 3 months having generated and saved 1.000.000 instances of this class, I need to start changing things eventually, for instance:
- Change the name of 2 attributes and 3 methods
- Drop one relationship
- Split the value of an attribute into 2 parts (for instance object.name into object.first_name object.last_name)
- Add 5 new methods and attributes
While I need to not break the data retrieval for historical data (That is, update registries or process accordingly on fetching).
Having considered that use-case:
What's the best approach for data retention, manipulation and retrieval? (speaking in terms of databases, design patterns and other technical means)