Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Homegrown Object Databases

One way to build an object database is to give each of your program's classes methods to save and restore their data in a relational database. For example, you could make a LoadFromDb method that takes as a parameter a Recordset object. It would examine the fields in the Recordset object's current record, and use their values to initialize the object.

To save an object, you would create a SaveToDb method that takes as a parameter a Recordset object. It would create a new record in the Recordset, initialize its fields using the object's data, and save the new record to the database.

You could build similar routines to locate a record with a specific key and create the corresponding object, update an existing object's record, and delete an object's record.

All this works quite well, but it is a fair amount of effort. You need to write several routines for each class you want to manage in this way. Each routine is customized for the exact definition of the class and the database table that contains it. If you add a field to the object, you need to update the database table, the class, and all the database routines.

  • + Share This
  • 🔖 Save To Your Account