Collection Object

Philip Mötteli philip.moetteli at econophone.ch
Mon Jul 31 18:33:28 CDT 2006


Am 31.07.2006 um 18:10 schrieb Ruslan Zasukhin:

> On 7/31/06 5:58 PM, "Philip Mötteli"  
> <philip.moetteli at econophone.ch> wrote:
>
>>> Can you make more details on this?
>>
>> As we found out, the normal use of a DBMS from an OO-program consists
>> of referencing records/objects. For this application an OODBMS is
>> much better suited. But NSArray/NSMutableArray also offers these
>> methods:
>>
>> - (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate
>>
>> - (void)filterUsingPredicate:(NSPredicate *)predicate
>>
>>
>> These methods actually access the internals/IVars/fields of the
>> member objects/records.
>
>> We could achieve a huge performance acceleration, if, instead of
>> deserializing all the member objects/records into RAM and applying
>> the predicate/query there, we let do this on the DBMS side.

>
>> So the NSPredicate would produce some SQL output, which would be sent
>> to the server, which would apply an SQL statement like this to the
>> collection table (NSSet,…)(I'm not an SQL expert!):
>>
>> SELECT *
>> FROM NSSet
>> WHERE a.x = y;
>>
>> And we would deserialize only the resulting OIDs.
>
> Lets on example:
>
> Table TC have next records with arrays, I will use simple values  
> for OIDs to
> simplify
>
> Table NSSet
> -------------------------------------------------
> RecID   f1      f2          f3 - Array
>  1      4       sdf         { 2, 3, 7, 9, 12 }
>  2      8       dfgd        { 3, 8, 10, 15 }
>  3      2       fhgf        { 4, 7, 11, 13, 24, 32, 45, 68 }
>
> Now we do SQL query
>
>     SELECT RecID
>     FROM  NSSet
>     WHERE f3.contains( 7 )
>
> Result - cursor on table NSSet with 2 records with RecIds of NSSet
>
>         ------------
> cursor    RecID
>         -------------
>             1
>             3

This type of query should never happen.


> Also we can want do
>
>     SELECT RecID, f3
>     FROM  NSSet
>     WHERE f3.contains( 7 )
>
>         ---------------------------------------------
> cursor      RecID    f3
>         ----------------------------------------------
>             1       { 2, 3, 7, 9, 12 }
>             3       { 4, 7, 11, 13, 24, 32, 45, 68 }
>
> Or you think about something else?

Two cases:

1.)	SELECT RecID
	FROM NSSet
	WHERE RecID=1 AND f3.contains(7)

	This would merely return a BOOL.


2.)	SELECT f3
	FROM NSSet
	WHERE RecID=1 AND f3.*.name='Ruslan'

Actually searching in the records referenced by the OIDs in f3.


> AS RESULT of search we must find NSSet instances, right ?

In case 2: Yes. In case 1: NO, just a BOOL.


Re
Phil



More information about the Valentina mailing list