• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData modeling a mutable attribute set for an entity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData modeling a mutable attribute set for an entity


  • Subject: CoreData modeling a mutable attribute set for an entity
  • From: Jesse Grosjean <email@hidden>
  • Date: Tue, 3 Jan 2006 10:30:11 -0500

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CoreData modeling a mutable attribute set for an entity
      • From: Jeff LaMarche <email@hidden>
    • Re: CoreData modeling a mutable attribute set for an entity
      • From: Jesse Grosjean <email@hidden>
  • Prev by Date: Re: MVC Alternatives?
  • Next by Date: Re: MVC Alternatives?
  • Previous by thread: Re: record:
  • Next by thread: Re: CoreData modeling a mutable attribute set for an entity
  • Index(es):
    • Date
    • Thread