• 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
Re: Core Data, questions about two models in an application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data, questions about two models in an application


  • Subject: Re: Core Data, questions about two models in an application
  • From: Jakob Olesen <email@hidden>
  • Date: Mon, 17 Jul 2006 17:41:38 +0200


On 17/07/2006, at 14.43, rakel wrote:

I'm developing an application where data about persons can be managed. My data model contain two types of entities, meta data and person data. A meta data entity can be e.g. Variable. A person entity can be e.g. Value. There is a relation between the Variable and the Value entities, and also between the Value and the Person entities -- a person has a value for a variable, another person has another value for the same variable.

E.g. let there be a Variable called with title "Operating System". Then the person with name "Piglet" can have a Value for this Variable with the "valueData" attribute set to "Windows" and the person "Winnie the Pooh" can have a Value for the same Variable with "valueData" attribute set to "Mac OS X".

First of all, you are meta-modelling. You are making a model of a model. Are you sure that is what you need? You can't just have an operatingSystem property on a Person?


One way is to start with a "Core Data Application" in XCode and have one data model with the entities Person, Value and Variable (this is how I currently do it).

I assume your data model looks like this:

Person <--->> Value <<---> Variable

Once again, this is complicated. Do you have all kinds of interesting attributes in the Variable entity? If you just have a name, get rid of the entity and simply put a variableName attribute in the Value entity.

Now to my question:

Another way could be to use a "Core Data Document Based Application" where each person is represented by one document. But since the Variables doesn't belong to any specific person, the Variable data cannot be part of the documents. Hence I would need two models, one model for the meta data and one model for the person data. Data for the "person data model" would be saved with each document. Data for the "meta data model" would be saved "somewhere else". Also, there must be a connection between the Value entity in the "person model" and the Variable entity in the "meta data model".

How do I do this? (Specifically, how do I maintain a relation between two entities in two different models?)

Check out the iClass example that comes with XCode. Basically, you save the URI of an object in a string attribute.


The example uses one stack for two stores. You probably want to use one stack for the metadata and one stack per document (as NSPersistentDocument does for you).

Since this means that you will be storing a variableURI string attribute in your Value entity, do consider if you could just call it variableName and get rid of the extra metadata store.

But really, documents with links to a global store is a bad idea. They are not really documents, you cannot move them to another computer (or user account for that matter).


_______________________________________________ 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: Core Data, questions about two models in an application
      • From: rakel <email@hidden>
References: 
 >Core Data, questions about two models in an application (From: rakel <email@hidden>)

  • Prev by Date: Re: Core Data and PostgreSQL
  • Next by Date: Re: Core Data and PostgreSQL
  • Previous by thread: Re: Core Data, questions about two models in an application
  • Next by thread: Re: Core Data, questions about two models in an application
  • Index(es):
    • Date
    • Thread