Software Engineering-Cardinality and Modality


The elements of data modeling—data objects, attributes, and relationships— provide the basis for understanding the information domain of a problem. However, additional information related to these basic elements must also be understood.
We have defined a set of objects and represented the object/relationship pairs that bind them. But a simple pair that states: object X relates to object Y does not provide enough information for software engineering purposes. We must understand how many occurrences of object X are related to how many occurrences of object Y. This leads to a data modeling concept called cardinality.

Cardinality. The data model must be capable of representing the number of occurrences objects in a given relationship. Tillmann defines the cardinality of an object/relationship pair in the following manner:
Cardinality is the specification of the number of occurrences of one [object] that can be related to the number of occurrences of another [object]. Cardinality is usually expressed as simply 'one' or 'many.' For example, a husband can have only one wife (in most cultures), while a parent can have many children. Taking into consideration all combinations of 'one' and 'many,' two [objects] can be related as

• One-to-one (l:l)—An occurrence of [object] 'A' can relate to one and only one occurrence
of [object] 'B,' and an occurrence of 'B' can relate to only one occurrence of 'A.'

• One-to-many (l:N)—One occurrence of [object] 'A' can relate to one or many occurrences
of [object] 'B,' but an occurrence of 'B' can relate to only one occurrence of 'A.'
For example, a mother can have many children, but a child can have only one mother.

• Many-to-many (M:N)—An occurrence of [object] 'A' can relate to one or more occurrences
of 'B,' while an occurrence of 'B' can relate to one or more occurrences of 'A.'

For example, an uncle can have many nephews, while a nephew can have many uncles. Cardinality defines “the maximum number of objects that can participate in a relationship”  . It does not, however, provide an indication of whether or not a particular data object must participate in the relationship. To specify this information, the data model adds modality to the object/relationship pair.

Modality. The modality of a relationship is 0 if there is no explicit need for the relationship to occur or the relationship is optional. The modality is 1 if an occurrence of the relationship is mandatory. To illustrate, consider software that is used by a local telephone company to process requests for field service. A customer indicates that there is a problem. If the problem is diagnosed as relatively simple, a single repair action occurs. However, if the problem is complex, multiple repair actions may be required.
The relationship, cardinality, and modality between the data objects customer and repair action is illustrated in the figure below.


Share this article :
 
Copyright © 2012. Best Online Tutorials | Source codes | Programming Languages - All Rights Reserved