Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Oct 16 Previous

The cardinal rules of SQL

When working with SQL, especially when optimizing it, you can come across the term 'high-cardinality column'. What does it mean?

A: The column data is referenced by many other tables.
B: The column data references many other tables.
C: It is a measure for the uniqueness of the data in the column.
D: The column fields can contain much data (f.i. BLOB or text fields)

Answer

Cardinality says something about the uniqueness of data in a database column. A column that contains user ids will be a (very) high-cardinality column, while the column that contains the user's sex will be a very low-cardinality column. The higher the cardinality of a column the more efficient indexed searches will be. So answer C is correct.

Whether or not a column or table is referenced by many other fields is not an important database statistic. And if data from a single column references many other tables is time to re-engineer the entire application. So answers A and B are false.

Fields that can contain much data are likely to be more unique than fields that just can contain one letter. In this way answer D has something to do with cardinality, but as an answer to the question it is false.