What is the definition of cardinality in SQL

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-oneone-to-many or many-to-many.

Leave a Comment