您在這裡

Relationships

8 九月, 2015 - 12:22

Another aspect of reality that must often be captured are the relationships that exist between entities in the real world. Relationships can be viewed in a variety of ways. From one perspective, relationships can be used to define the logical structure of a set of entities. Another important perspective is that which defines what various entities mean to each other.

The preceding section discussed the concept of a composite entity, an entity that contains other entities. A composite entity is one that defines structure. It represents the structure of containment between parent entities and their constituent entities. These are often called has-a relationships.

EX. TR-5:

The train-equipment schema discussed in example EX. TR-4 defines has-a relationships. (There are other types of relationships in that schema that we will discuss below.) Using the has-a relationship, we can make the following assertions about the train-equipment schema:

train_equipment has-a set of enginestrain_equipment has-a set of passenger_carstrain_equipment has-a set of dining_carstrain_equipment has-a caboose

The concept of data collections that have been referred to extensively in this section imply the set-theoretic concept of membership.A data collection can be viewed as a set, though most often not in strict set-theoretic terms since duplicate elements may sometimes exist. Nonetheless, an entity of a given type is often defined in terms of set of zero or more entities of that type.

EX. TR-6:

The train-equipment schema discussed in example EX. TR-4 is a composite entity that is partly composed of several types of sets of entities. Note the use of braces (i.e. “{“ and “}” ) in that example. The train-equipmentschema contains a set of engines, a set of passenger_cars, and a set of dining_cars. From the train_equipment entities perspective, it has several has-a relationships with respect to these sets as we discussed in example EX. TR-5. Relationships also can be viewed from the perspective of the elements of those sets. Using the element-of relationship, we can make the following assertion about the train-equipmentschema:

passenger_car having id=P143 is an element-of passenger_cars

Another perspective on relationships describes the cardinality of the associations between entities. There are three basic types of cardinalities: one-to-one, one-to-many, and many-to-many. These can be visualized in the following ways: