Cardinality
The cardinality of
a relation is how many instances there can be of
each entity that connect to the relation. For
example, Then for each subject there are L
students, and M staff teach N subjects, as each
member of staff may teach several courses. In
general, there are 3 different cardinalities:
-
One to
One, where each entity is related to
at most one of the other types of entity. E.g.
Each husband has at most one current wife, and
each wife has at most one current husband.
-
One to
Many, where each instance of an entity
on one side is related to numerous instances of
the other type of entity. E.g. a footballer is
related to only one club, but that club may
have many footballers.
-
Many to
Many, e.g. A teacher may teach several
subjects at different times, and a subject may
have several teachers for different days.
Constraints
For each attribute
there may be several constraints placed upon what
values it can take:
-
Domain of the
value
-
Format of values
(dd/mm/yyyy)
-
Range of values
(e.g. 1 to 10)
-
allow nulls ?
Does the attribute have to contain a value for
each instance of the entity?
Example of
Optionality and Cardinality

Attributes
Each entity type can always be
described in terms of attributes, and these
attributes will apply to all occurrences of that
given entity type. In the camera shop example,
all occurrences of the entity 'supplier' could be
described by an identifiable set of attributes,
including:
The Supplier Name, the Supplier Address,
Telephone Number, etcetera.
A given attribute belonging to a given entity
occurrence can only have one value. Therefore, if
a supplier could have more than one address or
telephone number then this should be determined
before defining the attributes of that entity
type.
In this example the defined entity may require
two or three address and/or telephone number
attributes. It is the maximum practical instances
of a given attribute that should be catered for
in the entity type definition.