Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Introduction to Power BI ยท Lesson 7 of 9

Module Six

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
7
Module 6: Understanding Data Models and Relationships Module 6: Understanding Data Models and Relationships in Power BI

Module 6: Understanding Data Models and Relationships in Power BI

Introduction

Imagine that you own a supermarket in Ibadan. You keep different records about your business.

You have one table containing customer information, another table containing product information, and another table containing sales records.

These tables contain different information, but they are connected because they belong to the same supermarket.

How can you make Power BI understand that a particular customer bought a particular product?

The answer is data modelling and relationships.

In this module, you will learn how to connect tables in Power BI so that information from different tables can work together.

What you will learn:
  • What a data model means.
  • Why data models are important.
  • What relationships between tables mean.
  • How to create relationships in Power BI.
  • One-to-many and one-to-one relationships.
  • What many-to-many relationships mean.
  • Primary keys and foreign keys.
  • How to understand a simple star schema.

1. What Is a Data Model?

A data model is the structure that shows how different tables and their information are organised and connected.

Think about a school.

A school may have different tables containing:

  • Student information.
  • Teacher information.
  • Class information.
  • Examination results.
  • School fees records.

These tables may contain information about the same students, teachers or classes.

A data model helps Power BI understand how the tables are connected.

Example: A School Data Model

Students Table Classes Table
Student ID: 101 Class ID: 1
Name: Ada Class Name: JSS 1
Class ID: 1 Class ID: 2
Name: John Class Name: JSS 2

The Students table contains a Class ID. The Classes table also contains a Class ID.

Power BI can use these matching values to connect the two tables.

2. Why Are Data Models Important?

Imagine that a supermarket has 10,000 sales records. Each record contains information about a product sold.

Instead of typing the product name and price repeatedly in every sales record, the supermarket can keep product information in a separate table.

Power BI can connect the sales table to the products table.

Data models are useful because they help you:

  • Organise information into different tables.
  • Reduce unnecessary repetition of information.
  • Connect related information.
  • Create reports using data from different tables.
  • Make data analysis easier to manage.
  • Build more reliable reports.
Remember: A data model is like a map that shows how different tables in your Power BI project are connected.

3. Understanding Primary Keys

A primary key is a column that uniquely identifies each record in a table.

For example, a school may have 500 students. Some students may have the same first name, but each student should have a unique Student ID.

Consider this table:

Student ID Student Name Class
101 Ada JSS 1
102 John JSS 2
103 Ada JSS 3

The Student ID column is the primary key because each student has a different ID.

Even though two students have the same name, their Student IDs are different.

Characteristics of a Primary Key

  • Each record must have a unique value.
  • It should not contain duplicate values.
  • It should not contain blank values.
  • It helps identify individual records.

4. Understanding Foreign Keys

A foreign key is a column in one table that refers to a key in another table.

Let's use our school example again.

Classes Table

Class ID Class Name
1 JSS 1
2 JSS 2
3 JSS 3

Students Table

Student ID Student Name Class ID
101 Ada 1
102 John 2
103 Mary 1

In the Classes table, Class ID is the primary key.

In the Students table, Class ID is a foreign key because it refers to the Class ID in the Classes table.

This connection helps Power BI understand which class each student belongs to.

Easy way to remember:
  • Primary key: Uniquely identifies a record in its own table.
  • Foreign key: Refers to a key in another table to create a connection.

5. What Is a Relationship in Power BI?

A relationship is a connection between two tables using related columns.

For example, a school may have a Students table and a Classes table.

Both tables contain a Class ID column. Power BI can use these columns to create a relationship.

When the relationship is created, Power BI can use information from both tables in the same report.

For example, you can create a report showing:

  • Class names.
  • Number of students in each class.
  • Average examination scores for each class.

6. Types of Relationships in Power BI

Power BI supports different types of relationships. The most common ones you should understand are one-to-many, one-to-one and many-to-many.

A. One-to-Many Relationship (1:*)

A one-to-many relationship means that one record in the first table can be connected to many records in the second table.

Example: One class can have many students.

Class ID Class Name
1 JSS 1
2 JSS 2
Student ID Name Class ID
101 Ada 1
102 John 1
103 Mary 2

JSS 1 has two students in this example. JSS 2 has one student.

One class can be connected to many students.

This is called a one-to-many relationship.

B. One-to-One Relationship (1:1)

A one-to-one relationship means that one record in the first table is connected to only one record in the second table, and vice versa.

Example: A school may keep student names in one table and additional student profile details in another table.

Student ID Name
101 Ada
102 John
Student ID Emergency Contact
101 08011111111
102 08022222222

Each student has one matching profile record in this example.

C. Many-to-Many Relationship (*:*)

A many-to-many relationship means that many records in one table can be connected to many records in another table.

Example: Students and school clubs.

One student can join many clubs, and one club can have many students.

Student ID Student Name
101 Ada
102 John
Club ID Club Name
1 Science Club
2 Press Club

A student-club membership table can record which students belong to which clubs.

For example:

Student ID Club ID
101 1
101 2
102 1

Ada belongs to both clubs, while John belongs to the Science Club.

This is a many-to-many situation. In a well-designed model, a separate membership table is commonly used to connect the two tables.

Important: Many-to-many relationships can be difficult to manage. A bridge table, such as the student-club membership table, often makes the model easier to understand and reduces unexpected calculation results.

7. Understanding the Model View

Model View is where you can see how tables are connected in Power BI Desktop.

It displays your tables as boxes. Lines between the boxes show relationships.

Each table box may show its column names.

You can use Model View to:

  • See all tables in your data model.
  • Create relationships between tables.
  • Edit existing relationships.
  • Delete relationships when necessary.
  • Understand how information flows between tables.

8. How to Create a Relationship in Power BI

Let's create a relationship between a Students table and a Classes table.

Step 1: Import Your Tables

  1. Open Power BI Desktop.
  2. Select Home and choose Get Data.
  3. Import your Excel workbook containing the Students and Classes tables.
  4. Load both tables into Power BI.

Step 2: Open Model View

  1. Look at the navigation icons on the left side of Power BI Desktop.
  2. Select Model View.
  3. You should see the tables you imported.

Step 3: Create the Relationship

  1. Find the Class ID column in the Classes table.
  2. Find the Class ID column in the Students table.
  3. Drag the Class ID column from Classes onto the Class ID column in Students.
  4. Review the relationship settings.
  5. Confirm that the Classes table is on the one side and the Students table is on the many side.
  6. Choose the appropriate cross-filter direction, usually Single for this simple example.
  7. Select OK or Save.

Power BI should now display a line connecting the two tables.

Another method: You can also use the Manage Relationships option on the Home or Model ribbon and select New to create a relationship.

9. Understanding Relationship Settings

When creating a relationship, Power BI provides settings that determine how the tables work together.

A. Cardinality

Cardinality describes how records in one table relate to records in another table.

Common options include:

  • One-to-many (1:*).
  • Many-to-one (*:1).
  • One-to-one (1:1).
  • Many-to-many (*:*).

B. Cross-Filter Direction

Cross-filter direction determines how filters can travel between related tables.

Two common options are:

  • Single: Filters flow in one direction across the relationship.
  • Both: Filters can flow in both directions.

For a simple school model, a single direction from the Classes table to the Students table is often a good starting point.

Be careful with Both: Using bidirectional filtering without understanding the model can create confusing or unexpected results. Use it only when there is a clear reason.

10. What Is a Star Schema?

A star schema is a common way of organising tables in a data model.

It has one central table called a fact table. Other tables, called dimension tables, connect to it.

The structure often looks like a star because several tables connect to the central table.

Example: Supermarket Sales Data Model

A supermarket may have these tables:

  • Sales Table: Records of products sold, quantities and sales amounts.
  • Products Table: Product names and categories.
  • Customers Table: Customer names and locations.
  • Dates Table: Dates, months, quarters and years.
  • Stores Table: Store names and locations.

The Sales table is the central fact table. The other tables provide information that helps explain the sales records.

Fact Table

A fact table stores business activities or events that you want to analyse.

Examples include:

  • Sales transactions.
  • Examination results.
  • Product orders.
  • Payments.

Dimension Table

A dimension table stores descriptive information about the people, products, places or dates connected to the activities.

Examples include:

  • Product details.
  • Customer details.
  • Store locations.
  • Calendar information.
Easy way to remember:

A fact table tells you what happened. A dimension table helps explain who, what, where or when it happened.

11. Common Data Modelling Mistakes

When creating relationships, beginners sometimes make mistakes that affect their reports.

Here are some common problems to avoid:

1. Using the Wrong Columns

Always connect columns that represent the same kind of information.

For example, connect Student ID to Student ID, not Student ID to Student Name.

2. Duplicate Values on the One Side

In a one-to-many relationship, the column on the one side must contain unique values.

If the Classes table contains Class ID 1 several times, Power BI may not be able to use it as the one side of that relationship.

3. Different Data Types

The columns used for a relationship should have compatible data types.

For example, one Class ID column should not be stored as text while the matching column is stored as a number without appropriate conversion.

4. Missing Matching Values

Check that the values in your related tables match correctly.

If a student has Class ID 5 but there is no Class ID 5 in the Classes table, that student may not match a class record.

5. Creating Too Many Relationships

Do not connect every table to every other table without a clear reason. A well-organised model is easier to understand and maintain.

12. Practical Activity: Build a School Data Model

Your Mission

You are working as a junior data analyst for a school in Ibadan. The school wants to analyse student information and examination results.

Create the following three tables in Excel.

Table 1: Students

Student ID Student Name Class ID
101 Ada 1
102 John 1
103 Mary 2
104 David 2
105 Grace 3

Table 2: Classes

Class ID Class Name
1 JSS 1
2 JSS 2
3 JSS 3

Table 3: Results

Result ID Student ID Subject Score
1 101 Mathematics 85
2 101 English 78
3 102 Mathematics 70
4 103 Mathematics 90
5 104 English 82
6 105 Mathematics 88

Instructions

  1. Create the three tables in an Excel workbook.
  2. Save the workbook as SchoolDataModel.xlsx.
  3. Open Power BI Desktop.
  4. Import all three tables.
  5. Open Model View.
  6. Connect Classes[Class ID] to Students[Class ID].
  7. Connect Students[Student ID] to Results[Student ID].
  8. Check that both relationships are one-to-many.
  9. Save your Power BI file.

Questions to Answer

  1. Which table contains the primary key Student ID?
  2. Which table contains the foreign key Class ID?
  3. Why can one class have many students?
  4. Why can one student have many examination results?
  5. Which table is the central table for storing examination results?

Extra Challenge

Create a table visual in Report View showing:

  • Student Name.
  • Class Name.
  • Subject.
  • Score.

Use fields from all three tables. If the relationships are correct, Power BI should be able to display the related information together.

13. Important Terms to Remember

Term Meaning
Data Model The structure showing how tables and information are organised and connected.
Relationship A connection between tables using related columns.
Primary Key A column that uniquely identifies each record in a table.
Foreign Key A column that refers to a key in another table.
One-to-Many One record in a table can be connected to many records in another table.
One-to-One Each record in one table matches one record in another table.
Many-to-Many Many records in one table can be connected to many records in another table.
Cardinality The type of relationship between two tables.
Fact Table A table containing events or activities to analyse.
Dimension Table A table containing descriptive information about facts.
Star Schema A data model with a central fact table connected to dimension tables.
Model View The Power BI area used to view and manage table relationships.

14. Module 6 Assessment: Test Your Knowledge

1. What is a data model?

  1. A computer game
  2. A structure showing how tables are organised and connected
  3. A type of keyboard
  4. A picture file

2. What is a primary key?

  1. A column that uniquely identifies each record
  2. A column containing duplicate names
  3. A chart title
  4. A Power BI colour

3. What is a foreign key?

  1. A password
  2. A column that refers to a key in another table
  3. A computer virus
  4. A chart type

4. Which relationship allows one class to have many students?

  1. One-to-one
  2. Many-to-many
  3. One-to-many
  4. No relationship

5. What does a one-to-one relationship mean?

  1. One record matches one record in another table
  2. One record matches 100 records
  3. All records are deleted
  4. Two tables cannot connect

6. Which Power BI view is used to see relationships between tables?

  1. Report View
  2. Model View
  3. Print View
  4. Reading View

7. What does cardinality describe?

  1. The colour of a chart
  2. The type of relationship between tables
  3. The size of a computer
  4. The number of report pages

8. What is a fact table?

  1. A table containing business events or activities to analyse
  2. A table containing only pictures
  3. A table containing passwords
  4. A table containing chart colours

9. What is a dimension table?

  1. A table containing descriptive information
  2. A table used only for deleting data
  3. A computer storage device
  4. A type of chart

10. What is a star schema?

  1. A type of computer monitor
  2. A model with a central fact table connected to dimension tables
  3. A chart showing stars
  4. A method of installing Power BI

Assessment Answer Key

  1. B - A structure showing how tables are organised and connected.
  2. A - A column that uniquely identifies each record.
  3. B - A column that refers to a key in another table.
  4. C - One-to-many.
  5. A - One record matches one record in another table.
  6. B - Model View.
  7. B - The type of relationship between tables.
  8. A - A table containing business events or activities to analyse.
  9. A - A table containing descriptive information.
  10. B - A model with a central fact table connected to dimension tables.

15. Module Summary

In this module, you learned how to organise and connect different tables in Power BI.

You discovered that:

  • A data model shows how tables are organised.
  • A primary key uniquely identifies a record.
  • A foreign key connects related tables.
  • Relationships allow Power BI to use information from different tables together.
  • One-to-many, one-to-one and many-to-many are important relationship types.
  • Model View helps you create and manage relationships.
  • A star schema uses a central fact table connected to dimension tables.
Congratulations!

You have completed Module 6 of Introduction to Power BI.

You now understand how different tables can work together to provide useful information.

Coming Up in Module 7

Introduction to DAX and Data Analysis

In the next module, you will learn about DAX, which stands for Data Analysis Expressions.

You will discover:

  • What DAX means.
  • Why DAX is important in Power BI.
  • How to write simple DAX formulas.
  • How to calculate totals and averages.
  • The difference between calculated columns and measures.
  • How to use DAX to answer business questions.

Get ready to make Power BI perform calculations for you!

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’