beautypg.com

Where do primary keys come from, Where do primary keys come from? 103 – Apple WebObjects 3.5 User Manual

Page 103

background image

Refining Your Model

103

3. Ensure that the delete rule is set to Cascade.

If the wizard created relationships for you, the relationship’s delete
rule should already be set to Cascade. You specified this in the wizard.
If you created your relationships by hand, you’ll have to set the delete
rule yourself.

4. Ensure that the Owns Destination box is checked.

As with the delete rule, if the wizard created relationships for you, the
relationship’s Owns Destination box should already be checked. If you
created your relationships by hand, you’ll have to check this box
yourself.

5. Check the Propagate Primary Key box.

A relationship that propagates its primary key propagates its key value
to newly inserted objects in the destination of the relationship. In this
case, checking the Propagate Primary Key box means that if you create
a new MovieRole and add it to a Movie’s list of MovieRoles, the Movie
object automatically assigns its

movieId

value as the value for the new

MovieRole’s

movieId

property.

This option is usually used with relationships that own their
destination. For more information on propagates primary keys, see
“Where Do Primary Keys Come From?” (page 103).

6. Ensure that Talent’s

movieRoles

relationship has its delete rule set to

Deny.

7. Ensure that Talent’s

movieRoles

relationship owns its destination.

8. Set Talent’s

movieRoles

relationship to propagate its primary key.

Where Do Primary Keys Come From?

Enterprise Objects Framework uses primary keys to identify enterprise
objects in memory, and it works best if you never change an enterprise
object’s primary key from its initial value. Consequently, applications
usually generate and assign primary key values automatically instead of
having users provide them. For example, the Movies application assigns a

movieId

value to a new movie when it’s created, and the value never changes

afterward. The Movies interface doesn’t even display

movieId

values because

they aren’t meaningful to users of the application.