Please note: this project is inactive since early 2006

2.3.4 Relationship

A relation is attached to an entity, and describes how an entity is related to another one.

Two kinds of relationships can be defined: simple and flattened relationship. However flattened relationshipsare not supported/tested yet.

Simple relationships join their (source) entity to a destination entity.

A relation may have the following properties:

the name of the relationship, unique within the entity.

this specifies how the object should react when it is deleted. Four options are possible options: NULLIFY, DELETE_DENY, DELETE_CASCADE and DELETE_NOACTION. We will use the model AuthorBooks defined in section 2.1.1, with entities Writer and Books, to highlight the differences between those 4 values:

This will be enforced when an object is inserted/updated or when it is deleted. See sections 4.4 and 4.6 for further details.

tells whether the Relationship's key (i.e. its name, for example: toBooks) is part of the class' API. It should be set in most cases.

multiplicityLowerBound, multiplicityUpperBound:
the multiplicty lower bound of a relationship defines the minimum number of objects that should be in relation. If the lower bound is zero, none are required: this is an optional relationship; if the lower bound is one or more, this is a mandatory relationship.

The multiplicity upper bound defines the maximum allowed number of objects in relations. It can be any positive number, given that it is always greater or equal than the lower bound. As a special exception, values -1 (minus one) or '*' serve to indicate an unconstrained upper bound.

The exact definition of to-one and to-many relationships (see 2.2) are then: to-one relationship: multiplicityUpperBound<=1, to-many relationship: multiplicityUpperBound>1.

designates the name of the destination entity.

the join's sematic can be either:

same as for Attributes, above.

a comment, for maintainers of the model.

The full definition of a relationship implies that it defines at least one join. However, this will not appear in PyModels, just in xml models. It's not really part of Entity-Relationship Modelling, it is just a mean to identify the correspondance between primary and foreign keys that defines a relationship. For this reasons, we will wait until section 2.5.5 to define them.

See also:

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted Logo