My school book Database Systems defines cardinality as follows:
The cardinality of a relation is the number of tuples it contains. By contrast, the number of tuples is called the cardinality of the relation and this changes as tuples are added or deleted. High-cardinality - many tuples, low-cardinality - few tuples.
While the Wikipedia article on Cardinality (SQL statements), defines it as follows:
Cardinality refers to the uniqueness of data values contained in a particular column (attribute) of a database table. The lower the cardinality, the more duplicated elements in a column. There are 3 types of cardinality: high-cardinality, normal-cardinality, and low-cardinality.
They might both be right, but i can't connect the two definitions as related definitions. A rephrase would be appriciated!
They are speaking the same thing and it has to do with tuples (relational algebra
) or rows (layman's term).
When it says high-cardinality are possible values of particular attribute (or field) that are unique and therefore the number of rows or tuples are higher:
Example:
StudentID Lastname Firstname Gender
101 Smith John M
102 Jones James M
103 Mayo Ann F
104 Jones George M
105 Smith Suse F
As far as as StudentID the cardinality
is high
because it is unique. In this it has five (5) tuples/rows.
On the other hand Lastname has normal cardinality, in particular there are only three (3) unique tuples/rows. Thus it has normal cardinality
.
And finally Gender has only two possible unique tuples thus Low Cardinality
.
You probably confuse Cardinality
here with Degree
of a relation which has something to do of the number of attributes/fields
in a relation (or table).
On the other hand the textbook for Database
when speaking of Cardinality
normally has to do with an entity in relation to another entity, that is, the number of possible relations occurences for an entity participating in a given relationship type. Thus for example for a binary relationship
cardinality
could be either one-to-one
, one-to-many
or many-to-many
.