Name

Tuple Table Pattern

Goal

To automatically store an object in a database in a way that is human-readable and easily extensible.

Participants

Data object

An object representing some data that we want to store.

Tuple table DAO

Takes a data object and converts its properties to name = value pairs.

Database table

Stores the rows of pairs.

Interactions

The tuple table DAO takes a data object and converts its properties to name=value pairs. It then writes those pairs into multiple rows of a database table. Each row of the table contains the object’s primary key, a field name, and a value. When the client needs to retrieve the data from the table, the DAO reads the name=value pairs and uses them to reconstitute an instance of the object.

Notes

The tuple table approach makes it easy to add new fields to the database, since you only need to extend the data object.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset