Documentation Archive Developer
Search
PATH  WebObjects 4.0 Documentation > EOF Tools and Techniques

Table of Contents Previous Section

Forming Relationships Across Models and Databases

The entities in one model can have relationships to the entities in another model. You can form such relationships even if the models map to different databases and different database servers.

When you add a model to a project, it becomes part of a model group, even if the model group only contains that one model (for more information on model groups, see the EOModelGroup class specification in the Enterprise Objects Framework Reference). Each subsequent model that you add to the project-either directly by adding the model to the project's Resources suitcase or indirectly by adding a framework that includes a model-automatically becomes part of the group. Entity names must be unique within a model group; you can't use the same entity name in two different models in the same group. Put another way, all the entities used in an application must have unique names.

To form a relationship from one model to another, use the Relationship Inspector as follows:

  1. Add a relationship to the entity you want to use as the source of the relationship.

    For example, you can form a to-one relationship between the Movie entity in the Movies sample database and the VideoTape entity in the Rentals sample database.

  2. In the Relationship Inspector, use the Model pop-up list to choose the model containing the entity you want to use as the destination of the relationship.

    Figure 27. Creating a Relationship Across Models

  3. Specify the relationship as you normally would.
Note: You can't flatten properties across databases, nor can you map inheritance hierarchies across databases (though you can do both of these things across models that map to the same database).

Table of Contents Next Section