Collection Object

Philip Mötteli philip.moetteli at econophone.ch
Mon Jul 31 15:37:38 CDT 2006


Am 31.07.2006 um 14:53 schrieb Ruslan Zasukhin:
> On 7/31/06 3:47 PM, "Ruslan Zasukhin" <sunshine at public.kherson.ua>  
> wrote:
>
>>> For case of 2 tables, we put pointer into MANY table. Right?
>>> So may be here we also should think in this way..
>>> Hmm, in this way hard...
>>>
>>>
>>> Well, then it seems you can use only next way
>>>
>>>
>>> In TC you make VarChar for example, and store data as:
>>>
>>>     121355354,1545115,154321354,13564351356,
>>>
>>> I.e. You make LIST of records with their OID values.
>>
>>>> Yes, it definitely more hard and I don't see the advantage over an
>>>> M:M table so far…
>>
>> Another way:
>>
>> So we have
>>
>>     TC - on left side                    Few tables on right side
>>
>> To link them we use special table:
>>
>>                   --------------------------
>>                      intermediate table
>>                   --------------------------
>>                      RecID_TC   |    OID
>
>
> Interesting. Main problem in your case that you want that
>
>     LEFT_TC  keep collection of records from SEVERAL tables on  
> right side.

Yes, kind of a BLOB of ObjectsPtr's.


> If talk about one table one Right Side than BinaryLink works  
> perfectly.

Exactly.


> But you want many tables on right side...

…and many records. Otherwise ObjectsPtr would work.


> Can you describe scenario of
>
>     * how records will be added/deleted into right tables ?

Freely, with no restrictions. They might even be created first and  
then later added to the collection/TC/NSSet.


>     * how are NSSet is born?
>         is it owner of records in collection?

It is one owner, but it's perhaps not the only one.


> Or just keep them?

Theoretically, these kind of collections also exists. But they are  
not officially offered by Apple/Foundation/GNUstep.


>         what must happens if I delete NSSet?

Nothing for me. I take care about deletion in the persistence layer.


>         what must happens if I delete record in T2 which is in some  
> set?

You can't. You first have to remove it from the set. But that  
shouldn't happen, because I take care of that in the persistence  
layer. If that happens, I have a bug.


>     * Let you have records in all tables, what next? What operations?
>         search?

That would be very great, because then, we could leverage the beauty  
of Valentinas relational part.


> Iteration?

I don't think so.
Indexation for the ordered kind of collection (NSArray).

Actually, the primitive methods of NSArray/NSMutableArray are:
- (unsigned)count

- (id)objectAtIndex:(unsigned)index

- (void)addObject:(id)anObject

- (void)insertObject:(id)anObject atIndex:(unsigned)index

- (void)removeLastObject

- (void)removeObjectAtIndex:(unsigned)index

- (void)replaceObjectAtIndex:(unsigned)index withObject:(id)anObject





> Navigation?

Probably needed for searching?


> Else? How ?

I don't know. I don't see anything more at the moment.


> May be exists sense try develop IDEAL abstraction that can manage  
> this ?

I help you, but I don't know the heuristics of how to develop such an  
ideal abstraction. But please ask me questions and I will try my best  
to find an answer.


> May be let's look into OO DBMS and ODMG? Although as I remember  
> they support
> collections that just keep some kind of general parent class. I.e.  
> They use
> advantage of inheritance..

I don't know, how they do it, but I know, that in Objective-C you  
have the generic data type 'id':

	typedef struct objc_class *Class;
	
	typedef struct objc_object {
		Class isa;
	} *id;


I don't think you need inheritance to implement collections. But I  
might be wrong…


Re
Philip



More information about the Valentina mailing list