Problem: How to make an object persistent on the disk?
Solution: Snapshot Pattern
Outline: An in-memory object ``lives'' only as long as the application program
is running. But an object might contain important data that needs to be retained essentially
forever, in particular, objects which represent information in a database.
Alternative 1: Use Java's serialization mechanism to implement Snapshot Pattern
Alternative 2: Use an SQL Relational database to implement Snapshot Pattern
For example, a relational table has a row per object:
mysql> select * from S; +------+-------+--------+--------+ | S_NO | SNAME | STATUS | CITY | +------+-------+--------+--------+ | S1 | Smith | 20 | London | ======> S1 Smith 30 Paris | S2 | Jones | 10 | Paris | | S3 | Blake | 30 | Paris | | S4 | Clark | 20 | London | | S5 | Adams | 30 | Athens | +------+-------+--------+--------+
When ``S1'' is constructed by Application, read the associated fields from the row
When ``S1'' mutates, modify the row to the new values
SEE CASE STUDY