Re: B*-trees

From: Christoph Rupp <chrrupp_at_rz.fh-augsburg.de>
Date: Fri, 12 Jan 2001 13:12:53 +0100
Message-ID: <3A5EF4C5.6CDC5B39_at_rz.fh-augsburg.de>


Hi Carl,

Carl Rosenberger wrote:

> How would you store the following to a relational database:
> (Pseudocode)
> Manager extends Employee extends Individual extends Person
>
> OODB:
> store(Manager);
>
> SQL?
OK - of course i can't provide you with an elegant solution. However - there are two ways coming to my mind, both with drawbacks:

  1. Every object provides a method void save(DBdataset *ds);

They fill the dataset with their member variables. Since all objects are inherited by a parent object which provides this virtual save-method, and since all those objects register themselves at a kind of Controller-class, as soon as they are created, the Controller-class can enumerate all its objects and tell them to save themselves. This works even with inherited classes like Manager extends Employee extends Individual extends Person, since the save-methods could call the save-method of their parent object(s) recursively.

2. template <T> void DB::SaveObject(T *obj); The database saves the raw data of an object (write((void *)obj, sizeof(*obj)). Will lead to problems when you have a member variable which is a pointer - the pointer address will be saved, but not the pointer contents...

Both solutions require discipline of the programmer, and this is always a BIG drawback :)

Of course i would try to avoid using SQL here. But that's the advantage of a database which you can link to your application - if the interface is extensible enough you just provide your own higher-level functionality. I guess that a database based on B-trees may not be the ideal way for saving objects, because you hardly can use indices or keys. But it should be possible to tweak it that it works. And maybe it's easier to provide OODB-functionality for a low-level database instead of storing huge datasets (telephone numbers, addresses, the typical data for relational databases) in an OODB.

> Take care about your youth.
> Define you goals.
> Define the quickest path to reach them.

I have a list of goals, written down in an excel sheet about 3 years ago. Writing software is part of them:
- it's my hobby and i like it

- it will give me experience and i may get a better job :)

One month ago i have written a list of 20 programs i want to write till my studies are over. I guess the list is far too long and some things will have to be skipped. But now i already have two of them nearly finished.

I'm 10 years younger then you but I may give you the best advice i can ever give: Get rid of your TV.
People look at you as if you were an alien if they hear that you have no TV. But the amount of time you gain is incredible.

Chris Received on Fri Jan 12 2001 - 13:12:53 CET

Original text of this message