Скачиваний:
140
Добавлен:
30.04.2013
Размер:
3.92 Mб
Скачать

Tighter English

We strongly recommend that an English sentence accompany each diagram to reinforce the meaning of the figure. Refer to Figure 4.3. English is often an ambiguous language. The statement that:

Automobiles must be driven by one and only one student.

actually means that:

Automobiles, which are in the database, must be driven by one and only one student.

It does not mean that:

One particular student drives some automobiles.

Another way to put this is:

Automobiles must be driven by one and only one student driver. Students may drive one and only one automobile.

To relieve ambiguity in the statement of the relationship, we will take the English statement from the relationship we have illustrated, and define four pattern possibilities for expressing our relationship. All binary relationships must be stated in two ways from both sides. As you will see, we will try to stick to the exact pattern match in the following examples, but common sense and reasonable grammar should prevail in cases where the pattern does not quite fit. There is nothing wrong with restating the precise language to make it more clear, but you have to say the same thing!

Pattern 1 — x:y::k:1

From the k side, full participation (k = 1 or M):

x's, which are recorded in the database, must be related to one and only one y. No x is related to more than one y.

Example:

Student:Advisor::M:1

Students must be advised by one advisor.

or

Students, which are recorded in the database, must be advised by one and only one advisor. No student is advised by more than one advisor.

The phrase "which are recorded in the database" has proven to be helpful because some database designers tend to generalize beyond the problem at hand. For example, one could reasonably argue that there might be a case where thus-and-so are true/not true, but the point is, will that case ever be encountered in this particular database? The negative statement is often helpful to solidify the meaning of the relationship.

Pattern 2 — x:y::k:1

From the k side, partial participation (k = 1 or M):

x, but not necessarily all x (which are recorded in the database), may be related to one and only one y. Some x's are not related to a y. x's may not be related to more than one y.

Example:

Student:Fraternity::M:1

Some students join a fraternity.

which becomes:

Students, but not necessarily all students (which are recorded in the database), may join a fraternity. Some students may not join a fraternity. Students may not join more than one fraternity.

Pattern 3 — x:y::k:M

From the k side, full participation (k = 1 or M):

x's, which are recorded in the database, must be related to many (one or more) y's. Sometimes it is helpful to include a phrase such as: No x is related to a non y (or) Non x are not related to a y. The negative will depend on the sense of the statement.

Example:

Automobile:Student::M:N

Automobiles are driven by (registered to) many students

which means:

Automobiles, which are recorded in our database, must be driven by many (one or more) students.

There are several ideas implied here. First, we are only talking about vehicles which are registered at this school. Second, in this database, only student cars are registered. Third, if an automobile from this database is driven, it has to be registered and driven by a student. Fourth, the "one or more" comes from the cardinality constraint. Fifth, there is a strong temptation to say something about the y, the M side back to the x, but this should be avoided as this is covered elsewhere in another pattern, and because we discourage inferring other relationships from the one covered. For example, one might try to say here that all students drive cars or all students are related to a vehicle — neither statement is true.

Pattern 4 — x:y::k:M

From the k side, partial participation (k = 1 or M):

x, but not necessarily all x, (which are recorded in the database) may be related to many (zero or more) y's. Some x may not be related to a y.

Example:

Course:Book::k:M

Some courses may require (use) many books.

which, restated, becomes:

Courses, but not necessarily all courses, (which are recorded in the database) may use many (zero or more) textbooks. Some courses may not require textbooks.

Note that due to partial participation (the single lines), the phrase "zero or more," is used for cardinality. If a relationship is modeled with the patterns we have used and then the English sounds incorrect, it may be that the wrong model has been chosen. Generally, the grammatical expression will be most useful in (1) restating the designed database to a naive user, and

(2) checking the meaning on the designed database among the designers. The complete version of the English may eventually prove tiresome to a database designer, but one should never lose track of the fact that a statement like "x are related to one y" can be interpreted in several ways unless it is "nailed down" with constraints stated in an unambiguous way. Furthermore, a negation statement may be useful to elicit a requirements definition, although at times the negation is so cumbersome it may be left off entirely. What we are saying is to add the negative or other noncontradictory grammar if it makes sense and helps with requirements elicitation. The danger in adding sentences is that we may end up with contradictory or confusing remarks.

Summary of the above Patterns and Relationships

Pattern 1:

Relationship is

x:y::1(full):1

Diagramatically

shown by Figure 4E

Figure 4E: Chen Model of 1(full):1 Relationship — Pattern 1

Pattern 1:

Relationship is

x:y::M(full):1

Diagramatically

shown by Figure 4F

Figure 4F: Chen Model of M(full):1 Relationship — Pattern 1

This is a very common form of a relationship which implies that an instance of ENTITY1 can only exist for one (and only one) of ENTITY2.

Pattern 2:

Relationship is

x:y::1(partial):1

Diagramatically

shown by Figure 4G

Figure 4G: Chen Model of 1(partial):1 Relationship — Pattern 2

Pattern 2:

Relationship is

x:y::M(partial):1

Diagramatically

shown by Figure 4H

Figure 4H: Chen Model of M(partial):1 Relationship — Pattern 2

In this case, some instances in ENTITY1 and ENTITY2 can exist without the relationship to the other entity.

Pattern 3:

Relationship is

x:y::1(full):M

Diagramatically

shown by Figure 4I

Figure 4I: Chen Model of 1(full):M Relationship — Pattern 3

Pattern 3:

Relationship is

x:y::M(full):N

Diagramatically

shown by Figure 4J

Figure 4J: Chen Model of M(full):N Relationship — Pattern 3

Pattern 4:

Relationship is

x:y::1(partial):M

Diagramatically

shown by Figure 4K

Figure 4K: Chen Model of 1(partial):M Relationship — Pattern 4

Pattern 4:

Relationship is

x:y::M(partial):N

Diagramatically

shown by Figure 4L