Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData modeling a mutable attribute set for an entity



I'm trying to design a CoreData model that will allow my object to have a mutable set of associated attributes. My goal is to create a generic database record that will allow users to add their own attributes to. But I'm having a hard time with the design. In particular I'm having a hard time figuring out how to design things so that it's possible to query multiple attributes with a single NSPredicate.

My design consists of an Entry managed object that has a relationship to multiple EntryAttribute objects. Each EntryAttribute has a string "key" (the name of the attribute) and a "value". Values are typed, so there is actually a hierchy of EntryAttributes entities. An abstract one that defines the "key" attribute. And concrete subclass entities for each value type. For example there is a EntryStringAttribute for subclass who's value is of type string and an EntryInteger16Attribute subclass who's value is of type integer16. A screenshot of this design is here:

With this design the user can create an Entry (generic record) and then define two attributes for that entry; a string "name" attribute and a integer "age" attribute. The problem is I can't find a good way to query across both attributes at the same time. For instance I'm not sure how to formulate a query (name == "joe" and age > 25) that will allow me to find the matching records.

So what's the best coredata design to support these features?

Querying across attributes doesn't seem to work in this case, I think because of the fact that there is a hierarchy of EntryAttributes and the "value" of those different subclasses will have different types. It might be that I'm just not forming the query correctly, so please let me know if I'm wrong and querying across attributes should be possible in this case.

Thanks for any help.

Jesse
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.