In SQL, cardinality refers to the number of unique values in particular column. So, cardinality is a numeric value that applies to a specific column inside a table.
In SQL, the term selectivity is used when discussing database indexes. The selectivity of a database index is a numeric value that is calculated using a specific formula. That formula actually uses the cardinality value to calculate the selectivity. This means that the selectivity is calculated using the cardinality – so the terms selectivity and cardinality are very much related to each other. Here is the formula used to calculated selectivity:
Formula to calculate selectivity:
Selectivity of index = cardinality/(number of rows) * 100%