PDA

View Full Version : Saving hierarchical structures of data.



psih128
29th July 2009, 03:27
Hi

I'm about to start working on a new project which involves saving hierarchical data structures, for instance lets suppose we have 4 types of objects: A, B, C, D, P1, P2

A has many B, or D
B has many C,
C has many D
and D has many P1, and P2

Here is an image describing this relationship.
http://img193.imageshack.us/img193/236/sketch.png

The relationship is not limited to the aggregation, lets say B and C might share common properties and be inherited from some other object.

Now I need a solution to store this kind of objects and their relationships. I was thinking of two ways:

1) Create a SQLite database and define corresponding tables and their relationships. Taking this path will require building some kind of Object Relational Mapper, which complicates thing quite a bit.

2) Use some kind of a serialization process (binary or XML??). Here things are not as complicated as in case of the pervious path.

In my understanding the best solution should leverage Qt capabilities as much as possible, so I wanted to get some advice from the community. Which way do you think is more favorable in terms of Qt framework? Maybe there is a better way? How would you approach building the ORM layer using Qt classes?

Thanks
Anton
Anton

wysota
30th July 2009, 08:33
I would go for the second solution. You can use QDataStream for the serialization if you want.