How to access child objects in hierarchical database setup
Arthur Clemens
aclemens at xs4all.nl
Sun Nov 2 18:34:03 CST 2003
On Sunday, November 2, 2003, at 04:42 PM, Ruslan Zasukhin wrote:
> on 11/2/03 15:51, Arthur Clemens at aclemens at xs4all.nl wrote:
>
>> 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?
>
> You cannot do this.
>
> Your structure must looks as:
>
> PARENT_Table CHILD_Table
> 1 : M
> ObjectPtr to parent table
>
>
> I.e. CHILD table keep pointers to Parent table.
> ALWAYS. This is RULE!
> Because pointer can points only one record.
OK. That is what I have. So far I understand.
> Back to your question.
> Let you have RecID of some ParentTable record,
> Now you want find its child records.
>
> You need do simply:
>
> ArraySet* pChilds = childTable.ptr.FindAsArraySet( &RecID );
>
>
> Note, since in most cases the count of childs will not be not huge, it
> is
> better to use ArraySet.
I was worried about the speed issue of retrieving the children.
Especially as I need to do that with every Record occurrence in view.
If I have a table view with visible window of 30 items, I need to do
this 30 times per update, for instance with scrolling...
Arthur
More information about the Valentina
mailing list