Cyber Monday: Ends tomorrow! Lock in Coursera Plus for $239/year and build skills all year.

Database Cardinality: A Brief Overview

Written by Coursera Staff • Updated on

Explore why database cardinality is a crucial concept within database design and management. Learn how to define cardinality and when to use different types of cardinality design.

[Featured Image] A learner works in a well-lit room with an open laptop and books on the desk as they study database cardinality and its various uses.

Key takeaways

  • Cardinality defines the relationship between two entities and influences how databases store, access, and maintain information.

  • High cardinality indicates a column in a table has many distinct values.

  • Cardinality in a database defines how tables relate through one-to-one, one-to-many, and many-to-many relationships.

By understanding cardinality, you can build your knowledge to effectively design database systems suited to the data types you work with. Read on to gain deeper insight into cardinality, why it is necessary, common types, and typical examples of how you might see cardinality chosen across professional industries for different purposes. Then, if you’re ready to learn how to create databases from scratch, enroll in the Meta Database Engineer Professional Certificate. Beginner-friendly, this program also covers command-line interface, pseudocode, software versioning, database administration, and more.

What is cardinality in a database?

Cardinality describes how tables in a database relate to each other. Your database's cardinality tells you if a value in one table links to just one or several values in a different table. This relationship can vary widely, from exclusive pairings to a vast network of connections.

What is high cardinality?

High cardinality means a column in a table has many unique values. For example, if you were dealing with a table that records every book published, the ISBN column would have high cardinality because each book has a unique ISBN. High-cardinality columns contain a high degree of unique information, making them useful for searches and indexing.

What does a low cardinality value indicate?

Low cardinality means a column has many repeated values. An example of this would be if your table included book genres rather than ISBNs. Since you can assign a finite number of genres, the table contains a limited range of values, resulting in low cardinality. Low-cardinality fields are easier to manage and can speed up certain queries but offer less granularity.

What is an example of cardinality?

As an example, consider a switch status description table in an electrical units database:

The “SwitchID” column has high cardinality because its values are always unique, since no two switches are the same. The “Status” column, however, has low cardinality as the values alternate between two values (ON and OFF

SwitchIDStatus
S1ON
S2OFF
S3ON
S4ON

Cardinality vs. ordinality

Cardinality and ordinality help explain two distinct aspects of data in databases: how records relate to one another and the order in which these records appear. Cardinality focuses on the uniqueness and relationship between data in different tables, essentially telling us how many connections exist between data sets. Ordinality describes the order of elements within a data set. While cardinality maps the landscape of data relationships, ordinality tells us about the sequence or position of data points within that landscape.

Cardinality vs. modality

Cardinality focuses on the types of relationships, while modality indicates whether a relationship must exist between entities.

For instance, modality can specify whether every learner must enroll in at least one course or if it’s optional for a learner to enroll in any course. If every learner must enroll, the modality is “one,” while if the relationship is optional, the modality is “zero.”

Cardinality can be one-to-one, one-to-many, or many-to-many, indicating how many instances of one entity relate to another.

Why is cardinality important in databases?

Cardinality is key to how well databases work, particularly when it comes to efficiently finding and storing information. Cardinality determines how data points link and organize within the database, impacting everything from how quickly you can retrieve the data to how accurately it’s stored.

For businesses that depend on fast access to data, properly setting up cardinality can lead to faster searches, more efficient data storage, and higher information accuracy. This means better service for customers and smoother operations. Cardinality helps organize data, ensuring you can quickly find what you’re looking for, correctly place new information, and record data with appropriate granularity.

Read more: Relational Database: Definition, Examples, and More

Types of cardinality in databases

When modeling data, you can choose three main types of cardinality: one-to-one, one-to-many, and many-to-many. You can make this choice depending on the type of data you have, the relationships you want to analyze, and your field's requirements.

One-to-one

One-to-one (1: 1) relationships link each value of a table to a singular value in another table. This type of relationship is less common than other cardinalities, and you typically find it used to add specific information to an entity's ID. For example, a database for employee management might have an “Employees” table and an “Employee Details” table, where each employee links to exactly one set of details, and each set of details links to precisely one employee.

One-to-many

One-to-many (1: N) relationships are among those you frequently encounter in database design. This design occurs when a single value in one table relates to multiple values in another table. For instance, in a library database, a single author can write multiple books, but only one author writes each book. This relationship enables efficient organization and retrieval of related records across tables.

Many-to-many

Many-to-many (M: N) relationships happen when several values in one table link to multiple values in another table. This type of relationship typically requires a third table to break down into two one-to-many relationships. For example, in a zoo database, an “animal” table and a “food” table might have a many-to-many relationship, as each animal can eat several types of food, and each type can feed several animals. The join table could be a “Feeding schedule” table, tracking which animals eat which food, effectively managing the many-to-many relationship.

Real-world applications of cardinality

Industries and sectors use cardinality to manage data and define relationships between data sets. Understanding cardinality helps structure data according to the natural relationships within the information being managed. For example, you might find cardinality types chosen for specific applications, such as:

  • E-commerce platforms: In an e-commerce database, the relationship between customers and orders is typically one-to-many, as a single customer can place multiple orders over time. This understanding helps design the database to efficiently manage customer data and their order histories.

  • Health care systems: Patient and appointment databases in health care systems may use one-to-one relationships for security. For example, a specific medical record might be linked to a single patient identifier, ensuring privacy and data integrity.

  • Educational institutions: Schools and universities can use databases where relationships between courses, students, and professors are many-to-many. Students can enroll in several courses with multiple professors, professors can teach several courses with many students, and each course can have multiple learners and professors associated with it.

  • Inventory management: In inventory management systems, the relationship between products and suppliers might be one-to-many if a supplier provides various products, but each product comes from a single supplier.

[Video thumbnail] Data engineering is easy

Check out our free resources for database professionals

Subscribe to Career Chat on LinkedIn to keep track of popular skills, tools, and certifications. Build or refresh your database skills with our other free digital resources:

Accelerate your career growth with a Coursera Plus subscription. When you enroll in either the monthly or annual option, you’ll get access to over 10,000 courses.

  • cplus logo

    Ends tomorrow! Cyber Monday savings on a year of skills

    CyberMonday-Ends Soon

Updated on
Written by:

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.