On Nov 12, 2008, at 6:38 AM, John Pannell wrote:

subway stations all over town). Each station has two or more "port" entities (i.e. the openings in and out of the station), which each have one or more "pipe" entities (i.e. the tunnels that connect the stations to one another). A single port might have more than one pipe in the case that there is a fork in the tunnel, and a train exiting the port could end up in one of a variety of stations.

The station has a to-many "ports" relationship with a cascade delete rule, and the port has a to-one "station" relationship with a cascade delete rule - these are inverses on one another. So now, if I delete a station, all of its ports will also be deleted from the object graph. Deleting a port, on the other hand, will remove it from the ports relationship on the station, but leave the station otherwise intact.

My trouble comes in relating the ports and the pipes. I'd like to model the pipe by having a to-one "sourcePort" relationship (to represent the port at the start of the tunnel - note: all of my tunnels are one-way) and a to-one "targetPort" relationship to represent the port at the end of the tunnel. A port would have a to- many relationship with pipe as the target entity. The difficulty comes in specifying an inverse... for the port's "pipes" relationship, I'm forced to choose from either the sourcePort or the targetPort as the inverse, and for the pipe's sourcePort or targetPort relationships, setting either to port's "pipes" breaks the inverse setting of the other.

You may be over-thinking Core Data's use of inverse relationships. Core Data wants inverse relationships to maintain graph integrity, such relationships that don't have to have anything to do with your application logic. Although subtle, I find this a clarifying distinction.

Anyway, I would recommend a multiple relationship setup:

1. Each pipe should have a to-one with port called "sourcePort", the inverse would be a to-many called "sourcePipes" 2. Each pipe should have a to-many with port called "targetPorts", the inverse would be a to-one called "targetPipe"

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to