Let’s say a program uses certain objects when it’s running and stores the objects and their data in a database when the program is not running. Is it more common to store the actual objects serialized in the database so that when the program is running again, they can be deserialized back into main memory and used by the program, or is it more common to store the fields of each object in the database and when the program is started up again, a new object is created with the fields as constructor arguments or set methods? The former (serialized objects) seems cleaner from the programmer’s perspective, but I can see the latter being preferable if other programs that don’t have the same exact class API to deserialize. What’s the trend in actual practice?
Let’s say a program uses certain objects when it’s running and stores the objects
Share
Normally one saves them as fields, that is, the discreet pieces of data in an object are stored in different fields.
This allows you to make ad-hoc querying of the data, which would be impossible (or very difficult) with a serialized form.
The point of a relational database is to minimize required storage and duplication while maintaining ACID.