• 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: Data Model Design Q: Translation [Resolved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data Model Design Q: Translation [Resolved]


  • Subject: Re: Data Model Design Q: Translation [Resolved]
  • From: Ben Lachman <email@hidden>
  • Date: Tue, 18 Jul 2006 02:09:13 -0400

Actually, I was looking for something a little more complicated.

I ended up solving my problem manually. I had originally wanted two relationships from my translation object to the two objects being translated. I also wanted these to be inverse relationships so CoreData could make everything happen magically. However, it doesn't seem that the data modeler can create two inverse one to many ( <--- >> ) relationships to the same entity.

What I ended up doing was creating three relationships: one to-many relationship from the entity to be translated to the translation entity, and then two to-one relationships from the translation entity back to the original entity. I then wrote some glue code to manage updating the to-many relationship (couple additions to setValue, deletion handling, and a addValue:forCollectionWithKey: method). The result of all this is that I can now translate back and forth between two objects (such as coins or anything else that has a name and amount substitution scheme) based on a dynamic list of translation entities.

->Ben

On Jul 12, 2006, at 4:00 PM, I. Savant wrote:

Ben:

Nobody's responded yet so I'll take a stab. If all you're asking is how to create entities with the relationships you've described in your ASCII graphic below, then this is very basic and simple with the data modeler.

If you require a "Coin" of a certain type to match a certain set of criteria to be allowed to be related to a substitution (or vice- versa), you will need to implement validation with whatever logic you choose.

  All of how-to's of this can be read here:

http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/ index.html

  For information on how to use the modeler, see XCode's help book.

  If I've missed your point, you'll probably need to elaborate.

On Jul 11, 2006, at 4:38 PM, Ben Lachman wrote:

I'm wondering how to design my data model so that I can include a substitution/translation object in my model. Basically I want an object that says 3 of this thing is equal to 4 of that thing, where the things are of the same class. A basic example would be substituting change: 5 pennies are equal to 1 nickel, 4 nickels are equal to 2 dimes, etc. The inverse of these is always true as well. This makes sense and seems pretty simple, but I can't figure out a decent way of doing this within the xcode data modeler. What I'd like is something like this:

[ Coin ] <---->> [ Substitution ] <<----> [ Coin ]

where [ Coin ] has a substitutions to-many relationship and [ Substitution ] has a pair of amounts (5 and 1 for instance) and relationships (to the nickel and penny coin objects).

Does anyone have an idea of how to do this in xcode?

Thanks,

->Ben
_______________________________________________
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


References: 
 >Data Model Design Q: Translation (From: Ben Lachman <email@hidden>)
 >Re: Data Model Design Q: Translation (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: KVO and the observeValueForKeyPath bottleneck
  • Next by Date: Re: NSPopUpButtonCell as NSTableView header problem
  • Previous by thread: Re: Data Model Design Q: Translation
  • Next by thread: Re: Data Model Design Q: Translation
  • Index(es):
    • Date
    • Thread