Collection Object
Philip Mötteli
philip.moetteli at econophone.ch
Mon Jul 31 14:35:32 CDT 2006
Am 31.07.2006 um 12:20 schrieb Ruslan Zasukhin:
> On 7/31/06 12:54 PM, "Philip M=9Atteli" =20
> <philip.moetteli at econophone.ch> wrote:
>
>>>>> T1 { RecID, OID, a1, a2, ... }, TableID =3D 1
>>>>>
>>>>> T2 { RecID, OID, b1, b2, ... }, TableID =3D 2
>>>>>
>>>>> T1 { RecID, OID, c1, c2, ... }, TableID =3D 3
>>>>>
>>>>> And you need table TC that can point any record of above 3 tabl=
es:
>>>>>
>>>>> TC { RecID, OID, ObjectPtr as ULLONG, ... }
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> First record of T1 has
>>>>>
>>>>> RecID =3D 1, OID =3D 0x00000010000001 =3D 4,294,967,29=
72
>>
>>>>> First record of T2 has
>>>>>
>>>>> RecID =3D 1, OID =3D 0x00000020000001 =3D 17,179,869,1=
84
>>>>>
>>>>> First record of T3 has
>>>>>
>>>>> RecID =3D 1, OID =3D 0x00000030000001 =3D 25,769,803,7=
76
>>>>>
>>>>> You see?
>>>>> OID =3D (TableID << 32) + RecID
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Now in TC you can have 3 records:
>>>>>
>>>>>
>>>>> TC, TableID =3D 4
>>>>> ------------------------------------
>>>>> ObjectPtr
>>>>> ------------------------------------
>>>>> 0x00000010000001
>>>>> 0x00000020000001
>>>>> 0x00000030000001
>>>>> ------------------------------------
>>
>>
>> So you mean, I have to create an old fashioned intermediate table =
TC?
>> With intermediate, I mean a table, that only serves to create an M=
:M
>> relation.
>
> No, no no
>
>> NSSet {RecID, OID}, TableID =3D 5
>>
>> First record of NSSet has
>>
>> RecID =3D 1, OID =3D 0x00000050000001
>>
>>
>> TC
>> ------------------------------------------------------------------=
---=20
>> ---
>> ObjectPtr =
=20
>> ObjectPtr
>> ------------------------------------------------------------------=
---=20
>> ---
>> 0x00000050000001 0x00000010000001
>> 0x00000050000001 0x00000020000001
>> 0x00000050000001 0x00000030000001
>> ------------------------------------------------------------------=
---=20
>> ---
>
>
> No, you do not need 5th table!
>
> I have give you FULL complete example:
>
> Table TC point three tables
>
>
>>> CREATE TABLE TC ( objects_ptr as ULLONG, ... Other fields ...=
)
>>
>> With TC you mean "Table Central"? Which should actually be my NSSe=
t
>> table?
>
> RIGHT.
>
> My TC - this is table Central, and it play role of YOUR NSSet :-)
But it uses several records. I have to use only ONE record, that =
=20
points to several other records in several tables at the same time. =
=20
One record in TC/NSSet is one instance of a collection object and =
=20
this instance/record has n pointers to other objects/records in other=
=20
tables.
> If you want do some kind of search
Not really. But if this is the only way=C9
> and return SEVERAL records in the same
> time, then all we can do is:
>
> return set of OID values (8 bytes.)
That's what I need. But starting from one record in TC/NSSet.
Again: The logic is, that one instance of a class is represented in =
=20
the database as one record of a table. So if I have an instance of a =
=20
collection object, which has n member objects, this must give somehow=
=20
one record in a table and this record must have n pointers to other =
=20
records. (Where 'n' can be from 0 to =B0.)
> Or e.g. Find in table TC some set of records and get cursor on that=
=20
> records:
>
> pCursor
>
>
> Then this cursor allow us iterate records to extract OID values =
=20
> and ...
Could also be a solution, though seems to me a little bit tinkered.
> As far as I see task, we can have some set of OID values,
> Then we do iteration of this set, and do GOTO to some OID.
Ok. But starting from one record.
> Now you can do this manually. For this:
>
> * in T0 you need add one more field Kind (ULONG) which keep TableID=
=20
> of child
> record.
>
> * in T1 - T3 you add ObjectPtr (Unique) to parent table T0.
>
>
> As you can see here again play TableIDs, but solution is built on =
=20
> ObjectPtr
> links, which do have cascade deletion, and this can be advantage.
>
> And this solution in manual way is more hard it seems. More jumps =
=20
> also..
Yes, it definitely more hard and I don't see the advantage over an =
=20
M:M table so far=C9
Re
Phil
More information about the Valentina
mailing list