Interview Questions for Business Analysts and Systems Analysts


Recent Interview Questions | Search | Subscribe (RSS)

?
INTERVIEW QUESTION:

What is Cardinality?

Posted by Adrian M.

Article Rating // 1288 Views // 0 Additional Answers & Comments

Categories: Data Analysis & Modeling

ANSWER

Before we discuss cardinality as it is used with databases and data modeling, let’s first look at the origin of the adjective cardinal.

If you were to look up the word cardinal in the dictionary you will probably find something like:

Cardinal (adj) = of great importance; main; principal; essential

You’ve surely heard about the cardinal rule referring to the rule of most importance.

You probably also heard about cardinal numbers which are the basic numbers we all know (1, 2, 3, etc.) and use everyday.

Continuing with mathematics, we move on to cardinality:

Cardinality (noun) = the number of elements of a given set; for example, set B = {x, y, z} is set to have a cardinality of 3 because it contains three elements.

When discussing data values in a column of a database table:

Cardinality = to the number of unique values across all the rows. 

When it comes to data in a given table, you might also here these two terms:

  • High Cardinality = having a larger number of unique values (compared to the total number of rows).  A column containing the employee numbers of a company would have a high cardinality because the employee numbers are expected to be unique.

  • Low Cardinality = having a low number of unique values (compared to the total number of rows).  A column containing the day of the week (Monday, Tuesday, Wednesday, …) for appointments in a doctor’s office would have a low cardinality because there will be countless appointments occurring on a given day of the week.

Now we are ready to move on to modeling - data modeling and database modeling - which is the subject of this question:

Cardinality = is a qualifier of the relationship between two logical entities (in data modeling) or between two tables (in database modeling) which specifies the numerical relationship (count) of rows in one table and rows in another table.  The cardinality is expressed in relationship form such as: one-to-one or one-to-many. 

For example, if you consider two simple entities Student and Course, it can be said that a Student has a one to many relationship to Course(s) because a student can enroll in more than one course at a time.

In practice, the cardinality of data modeling is visible in some sort of data model or diagram such as: Entity-Relationship Diagram (ERD) or UML Class Diagram.

Setting the diagramming methodology aside, the basic cardinality relationships are:

Cardinality

Simple Notation

Description

Example

one-to-one

1 - 1

One entity (or row in a table) can relate to only one entity (or row in another table).

One employee has only one social security number and, vice versa, a social security number belongs to only one employee.

one-to-many

1 - *

One entity (or row in a table) can relate to many entities (or rows in another table).

One order can contain many items.

many-to-many

* - *

Many entities (or rows in a table) can relate to many entities (or rows in another table).

Many students are enrolled in many classes and many classes can have many students.

 

In the above simple notation “1” means “exactly one” and “*” means “one or more”.  

In data modeling cardinality, the above three basic relationships can get a bit more complex (but not too complex) by introducing the concept of optionality.  Using an example above, while a student may be enrolled in a class she doesn’t have to.  Maybe she’s taking a semester off.  Similarly, while a class can have many students, it may not have any (if nobody signed up yet).

Let’s summarize the simple cardinality notation:

Notation

Definition

1

exactly one

0..1

zero or one

*

many (but at least 1)

0..*

zero or many

 

Finally, let’s put these in practice with a couple of more examples:

Example

Entities

Notation

Verbalization

Consider the relationship between customers and checking accounts at a bank.  A customer can have many checking accounts but it may not have any.  A checking account has to have at least one owner but it may have more than one.

Customer, Checking Account

*  -  0..*

Many to Zero-or- Many

Now consider persons and driver’s licenses.  A person may or may not have a driver’s license but a driver’s license belongs to only one person.

Person,

Driver’s License

1 - 0..1

One to Zero-or-One

 

Your turn: What are your thoughts on cardinality?

RATE THIS TOPIC

ADDITIONAL ANSWERS / COMMENTS

Only registered users may post comments.

Do your homework prior to the business analysis interview!

Having an idea of the type of questions you might be asked during a business analyst interview will not only give you confidence but it will also help you to formulate your thoughts and to be better prepared to answer the interview questions you might get during the interview for a business analyst position.  Of course, just memorizing a list of business analyst interview questions will not make you a great business analyst but it might just help you get that next job.

 



 




Select ModernAnalyst Content

Register | Login

Copyright 2006-2022 by Modern Analyst Media LLC