I just want to confirm my observations/thinking regarding collections
in SQLPO.
Visualize two classes, Group and Item, as an example. They might look
like this:
@interface Group : SQLitePersistentObject
{
NSString *name;
NSMutableArray *items;
}
@interface Item : SQLitePersistentObject
{
NSString *name;
// various other ivars
Group *group;
}
Group's items would include an array of potentially hundreds of Item
instances, and Item's group would link back to the parent group.
Simple enough.
But from what I can see, if I want to load a Group object to simply
edit the name, via [Group findByPK:0] or similar, it looks like it'll
populate the items array with all of the Item instances -- potentially
loading hundreds of objects unnecessarily. Similarly, when I -save
the Group object, it'll delete and insert cross-references for all
those objects, when they haven't changed. Therefore, it seems I
should instead omit the items array.
A related confusion: when I want to populate the list of items in a
specific group, I would presumably get the item properties via a
"WHERE group=<something>" criteria. But what should the "<something>"
be? The pk of the group?
Of course, another way to do it would be to instead use the pk of the
group as the property; that'd be easy to search on. But that doesn't
feel as elegant as using the object itself (and I would want to load
the associated Group when loading an Item).
--
David Sinclair, Dejal Systems, LLC - d...@dejal.com
Dejal blog - http://www.dejal.com/blog/
Cocoa code - http://www.dejal.com/developer/
Twitter - http://twitter.com/dejal/