Previous Next

Forming Relationships in the Diagram View

To create a relationship in diagram view, Control-drag from a source attribute to a destination attribute, as shown in Figure 5-4.

Figure 5-4 Control-drag from source key to destination key to form a relationship

[image: ../Art/control_drag_rel.gif]

The cardinality of the relationship is determined by the primary key characteristic of the destination attribute. If the destination attribute is the entity’s primary key, the relationship is modeled as a to-one relationship. If the destination attribute is a foreign key, the relationship is modeled as a to-many relationship.

Control-dragging to form a relationship actually creates two relationships: one in the source attribute’s entity and an inverse relationship in the destination attribute’s entity. In Figure 5-5, Control-dragging from Person.personPhotoID (a foreign key) to PersonPhoto.personPhotoID (a primary key) creates a to-one relationship from the Person entity to the PersonPhoto entity and a to-many relationship from the PersonPhoto entity to the Person entity.

Figure 5-5 Control-dragging also creates an inverse relationship

[image: ../Art/after_control_drag.gif]

In Figure 5-5, the single line indicating the relationships between the Person and PersonPhoto entities should not be mistaken for a “bidirectional” relationship, which is not possible in the object-relational model. It is actually two relationships but when you create a relationship in diagram view, it appears as a single line.

For the personPhoto relationship, it doesn’t make sense for the inverse relationship (persons in PersonPhoto) to be a to-many relationship. You can make it a to-one relationship in the Relationship Inspector as well as set other characteristics of the relationship. The Relationship Inspector is described in detail in “Forming Relationships in the Inspector” and “Forming Relationships Across Models and Data Sources”.




Previous Next


© 2002 Apple Computer, Inc. (Last Updated November 2002)