How to access child objects in hierarchical database setup
Arthur Clemens
aclemens at xs4all.nl
Sun Nov 2 14:51:35 CST 2003
I'm find myself still struggling with fundamental Valentina concepts,
as I am switching from SQL based db to Valentina db. Here I have my
hierarchical database setup:
Record (holder of the following children:)
SloveneWord (n times possible per Record)
RecordSection (n times possible per Record; holder of the
following children:)
Translation (1 each Record Section)
Grammar (1 each Record Section)
// some other fields
I am trying to do this without SQL queries, because I have the
impression these queries will be slower than accessing variables
directly.
Now I want to show all SloveneWords (with sort order = 0) in a table
view. This has to be a very fast lookup.
So I have a FBL_BitSet with all records
(myDatabase->SelectAllRecords(); I store them in a FBL_ArraySet with a
FBL_ArraySetIterator to access it). Then I retrieve the SloveneWord
with the method itemAtIndex:
- (id)itemAtIndex:(int)index
{
mIterator->GoTo(index);
FBL_REC_ID RecID = **mIterator; // mIterator is set up as pointer,
hence the double **
// ... have the RecID and now what?
}
All works - I get the record id. But now: how does the Record know of
its children? Do I need to set up a Find to retrieve all SloveneWords
with mfParentPtr equals the record id? (Like in the Plant example, the
very last page?) Or is it faster to let Record have pointers to its
children, for instance:
VDK_ObjectPtr mfSloveneWordPtr; // pointer to boSloveneWord
... and then to access them directly?
If so, how do I update Record to access the mfSloveneWordPtr pointer?
Something like:
inline void boRecord::setSloveneWordPtr(FBL_REC_ID inID) {
// ...
}
I guess my question boils down to: what is the logical method for
Valentina and what is best for speed?
Arthur Clemens
More information about the Valentina
mailing list