<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: OmondiM</title>
    <description>The latest articles on Forem by OmondiM (@mercyomondig).</description>
    <link>https://forem.com/mercyomondig</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3818870%2F2c863a58-4d88-4ec8-b466-bc4dc7c3dfbb.png</url>
      <title>Forem: OmondiM</title>
      <link>https://forem.com/mercyomondig</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mercyomondig"/>
    <language>en</language>
    <item>
      <title>Understanding Data Modeling in Power BI: Joins, Relationships and Schemas Explained</title>
      <dc:creator>OmondiM</dc:creator>
      <pubDate>Mon, 13 Apr 2026 09:29:49 +0000</pubDate>
      <link>https://forem.com/mercyomondig/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-imf</link>
      <guid>https://forem.com/mercyomondig/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-imf</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;
What is Data Modeling?

&lt;ul&gt;
&lt;li&gt;Key Components of Data Modeling in Power BI&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Schemas in Power BI

&lt;ul&gt;
&lt;li&gt;Star Schema&lt;/li&gt;
&lt;li&gt;Snowflake Schema&lt;/li&gt;
&lt;li&gt;Flat Schema&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Relationships in Power BI

&lt;ul&gt;
&lt;li&gt;Types of Relationships&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Cardinalities Explained

&lt;ul&gt;
&lt;li&gt;Cardinality Options in Power BI&lt;/li&gt;
&lt;li&gt;Cross-Filter Direction&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Joins in Power BI

&lt;ul&gt;
&lt;li&gt;Types of Joins in Power Query&lt;/li&gt;
&lt;li&gt;DAX Functions for Joins&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Best Practices for Data Modeling in Power BI&lt;/li&gt;

&lt;li&gt;Common Data Modeling Challenges and Solutions&lt;/li&gt;

&lt;li&gt;Advanced Concepts&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;li&gt;Additional Resources&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Data modeling is the foundation of effective data analysis and visualization in Power BI. It involves structuring data in a way that allows for efficient querying, relationships and insights. This article delves into the core concepts of data modeling in Power BI, including schemas, relationships, cardinalities and joins. By mastering these elements, you can create robust, scalable, and performant Power BI reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Data Modeling?
&lt;/h2&gt;

&lt;p&gt;Data modeling in Power BI refers to the process of organizing and structuring data from various sources into a coherent model that supports analysis and reporting. It involves creating relationships between tables, defining schemas and ensuring data integrity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Components of Data Modeling in Power BI
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tables&lt;/strong&gt;: The basic building blocks containing data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships&lt;/strong&gt;: Connections between tables based on common fields&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Schemas&lt;/strong&gt;: The overall structure and organization of the data model&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Joins&lt;/strong&gt;: Methods of combining data from different tables&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Schemas in Power BI
&lt;/h2&gt;

&lt;p&gt;A schema represents the logical structure of your data model. Power BI supports several schema types:&lt;/p&gt;

&lt;h3&gt;
  
  
  Star Schema
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Structure&lt;/strong&gt;: One central fact table surrounded by dimension tables&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Simple, efficient for querying, optimized for analytical workloads&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case&lt;/strong&gt;: Ideal for most Power BI reports and dashboards&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notes&lt;/strong&gt;: Star schema avoids duplication by separating facts from dimensions. Normalization organizes data to reduce duplication and improve data integrity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Snowflake Schema
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Structure&lt;/strong&gt;: Dimension tables are normalized, creating a snowflake-like pattern&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Reduces data redundancy, maintains referential integrity&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case&lt;/strong&gt;: When you need to maintain normalized data structures&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Flat Schema
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Structure&lt;/strong&gt;: All data in a single table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Simple for very small datasets and quick prototyping&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limitations&lt;/strong&gt;: No relationships are needed because only one table exists; there are no separate fact or dimension tables. This leads to data duplication, and if a value changes it must be updated in many rows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case&lt;/strong&gt;: Small-scale analysis or when relationships are not needed, but not optimized for production or scalable analytics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Relationships in Power BI
&lt;/h2&gt;

&lt;p&gt;Relationships define how tables connect to each other. They enable Power BI to understand how data relates across different tables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Relationships
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;One-to-One (1:1)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Each record in Table A corresponds to exactly one record in Table B&lt;/li&gt;
&lt;li&gt;Rare in practice, often used for security or performance reasons&lt;/li&gt;
&lt;li&gt;Example: Employee table and Employee Details table (one employee has one set of details)
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   graph TD
       A[Table A] --&amp;gt;|1| B[Table B]
       B --&amp;gt;|1| A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;One-to-Many (1:*)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Most common relationship type&lt;/li&gt;
&lt;li&gt;One record in Table A can relate to multiple records in Table B&lt;/li&gt;
&lt;li&gt;Example: Customer table and Orders table (one customer can have many orders)
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   graph TD
       A[Table A] --&amp;gt;|1| B[Table B]
       B --&amp;gt;|*| A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Many-to-One (*:1)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inverse of one-to-many&lt;/li&gt;
&lt;li&gt;Multiple records in Table A relate to one record in Table B&lt;/li&gt;
&lt;li&gt;Example: Orders table and Customer table (many orders belong to one customer)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Many-to-Many (&lt;em&gt;:&lt;/em&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complex relationship requiring a bridge table&lt;/li&gt;
&lt;li&gt;Records in both tables can relate to multiple records in the other&lt;/li&gt;
&lt;li&gt;Example: Students and Courses (students can take many courses, courses can have many students)
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   graph TD
       A[Table A] --&amp;gt;|*| B[Table B]
       B --&amp;gt;|*| A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Joins in Power BI
&lt;/h2&gt;

&lt;p&gt;While Power BI uses relationships for data modeling, joins are used in DAX expressions and Power Query.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Joins in Power Query
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inner Join&lt;/strong&gt;: Returns only matching rows from both tables&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Left Outer Join&lt;/strong&gt;: Returns all rows from the left table and matching rows from the right table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Right Outer Join&lt;/strong&gt;: Returns all rows from the right table and matching rows from the left table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full Outer Join&lt;/strong&gt;: Returns all rows from both tables&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Left Anti Join&lt;/strong&gt;: Returns rows from the left table that don't have matches in the right table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Right Anti Join&lt;/strong&gt;: Returns rows from the right table that don't have matches in the left table&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  DAX Functions for Joins
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RELATED()&lt;/code&gt;: Retrieves related values from another table&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RELATEDTABLE()&lt;/code&gt;: Returns a table of related values&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;LOOKUPVALUE()&lt;/code&gt;: Looks up a value in a table based on criteria&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sample Examples
&lt;/h3&gt;

&lt;p&gt;Let's use two sample tables to demonstrate joins:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customers Table:&lt;/strong&gt;&lt;br&gt;
| CustomerID | CustomerName | City |&lt;br&gt;
|------------|--------------|------|&lt;br&gt;
| 1 | John Doe | New York |&lt;br&gt;
| 2 | Jane Smith | Los Angeles |&lt;br&gt;
| 3 | Bob Johnson | Chicago |&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Orders Table:&lt;/strong&gt;&lt;br&gt;
| OrderID | CustomerID | Product | Amount |&lt;br&gt;
|---------|------------|---------|--------|&lt;br&gt;
| 1001 | 1 | Laptop | 1200 |&lt;br&gt;
| 1002 | 1 | Mouse | 25 |&lt;br&gt;
| 1003 | 2 | Keyboard | 75 |&lt;br&gt;
| 1004 | 4 | Monitor | 300 |&lt;/p&gt;

&lt;h4&gt;
  
  
  Power Query Examples
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inner Join&lt;/strong&gt; (Matching customers with their orders):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Table&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Customers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CustomerID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CustomerID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;JoinKind&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Inner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: Only customers with orders (John Doe and Jane Smith)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Left Outer Join&lt;/strong&gt; (All customers, with orders if available):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Table&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Customers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CustomerID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CustomerID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;JoinKind&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LeftOuter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: All customers, with null values for customers without orders&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Full Outer Join&lt;/strong&gt; (All customers and all orders):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Table&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Customers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CustomerID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CustomerID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;JoinKind&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FullOuter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: All records from both tables, with nulls where no match&lt;/p&gt;

&lt;h4&gt;
  
  
  DAX Examples
&lt;/h4&gt;

&lt;p&gt;Assuming a relationship exists between Customers[CustomerID] and Orders[CustomerID]:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;RELATED()&lt;/strong&gt; - Get customer name for each order:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Customer Name = RELATED(Customers[CustomerName])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Orders table, this returns the customer name for each order.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;RELATEDTABLE()&lt;/strong&gt; - Calculate total orders per customer:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Total Orders = COUNTROWS(RELATEDTABLE(Orders))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Customers table, this counts the number of orders for each customer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;LOOKUPVALUE()&lt;/strong&gt; - Find customer city by ID:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Customer City = LOOKUPVALUE(Customers[City], Customers[CustomerID], Orders[CustomerID])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Orders table, this looks up the city for the customer who placed each order.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using Relationships in Measures&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Total Sales = SUMX(RELATEDTABLE(Orders), Orders[Amount])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Calculates total sales amount for each customer using the relationship.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Data Modeling in Power BI
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Use Star Schema When Possible
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Simplifies queries and improves performance&lt;/li&gt;
&lt;li&gt;Easier for end-users to understand&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Avoid Many-to-Many Relationships When Possible
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Can lead to ambiguous results and performance issues&lt;/li&gt;
&lt;li&gt;Use bridge tables or change your data structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Use Descriptive Column Names
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Makes your model self-documenting, for example use &lt;code&gt;customer_id&lt;/code&gt; in both the Customers dimension and fact tables.&lt;/li&gt;
&lt;li&gt;Improves user experience in report building&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Leverage Date Tables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create dedicated date dimension tables&lt;/li&gt;
&lt;li&gt;Enables time intelligence functions&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Minimize Calculated Columns
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use measures instead when possible&lt;/li&gt;
&lt;li&gt;Calculated columns increase model size&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Handle Missing Relationships
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;USERELATIONSHIP()&lt;/code&gt; function for inactive relationships&lt;/li&gt;
&lt;li&gt;Be aware of potential performance impacts&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Optimize for Performance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Remove unnecessary columns&lt;/li&gt;
&lt;li&gt;Use appropriate data types&lt;/li&gt;
&lt;li&gt;Consider data compression&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Data Modeling Challenges and Solutions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Challenge: Circular Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Review your relationships and consider restructuring your model&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Challenge: Ambiguous Relationships
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Ensure clear, single-path relationships between tables&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Challenge: Performance Issues with Large Datasets
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Implement incremental refresh, use aggregations and optimize queries&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advanced Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Role-Playing Dimensions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A single table serving multiple roles (e.g., Date table for Order Date and Ship Date)&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;USERELATIONSHIP()&lt;/code&gt; in DAX to specify which relationship to use&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Parent-Child Hierarchies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Self-referencing relationships&lt;/li&gt;
&lt;li&gt;Useful for organizational charts or bill of materials&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Composite Models
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Combine imported data with DirectQuery sources&lt;/li&gt;
&lt;li&gt;Allows for large datasets with real-time capabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Effective data modeling is crucial for building powerful, efficient Power BI solutions. By understanding schemas, relationships, cardinalities and joins, you can create data models that not only perform well but also provide meaningful insights. Remember to follow best practices, regularly review your models, and adapt to changing business requirements.&lt;/p&gt;

&lt;p&gt;Power BI's flexibility allows for various modeling approaches, but starting with a solid foundation in these core concepts will set you up for success in your data analytics journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-relationships-understand" rel="noopener noreferrer"&gt;Power BI Documentation: Model Relationships&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.guru99.com/star-snowflake-data-warehousing.html" rel="noopener noreferrer"&gt;Star Schema vs. Snowflake Schema&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dax.guide/" rel="noopener noreferrer"&gt;DAX Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article provides a comprehensive overview of data modeling concepts in Power BI. For hands-on practice, try creating models with sample datasets and experiment with different relationship types.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>beginners</category>
      <category>microsoft</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Beginner’s Guide to SQL: DDL, DML, WHERE &amp; CASE WHEN</title>
      <dc:creator>OmondiM</dc:creator>
      <pubDate>Mon, 13 Apr 2026 08:13:22 +0000</pubDate>
      <link>https://forem.com/mercyomondig/beginners-guide-to-sql-ddl-dml-where-case-when-3j82</link>
      <guid>https://forem.com/mercyomondig/beginners-guide-to-sql-ddl-dml-where-case-when-3j82</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Overview&lt;/li&gt;
&lt;li&gt;DDL vs DML&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Core SQL Operations&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CREATE (DDL)&lt;/li&gt;
&lt;li&gt;INSERT&lt;/li&gt;
&lt;li&gt;UPDATE&lt;/li&gt;
&lt;li&gt;DELETE&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Filtering with WHERE&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IN / NOT IN&lt;/li&gt;
&lt;li&gt;LIKE&lt;/li&gt;
&lt;li&gt;BETWEEN&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;CASE WHEN for Data Transformation&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;If you're starting out with SQL, understanding how to create, manipulate, and query data is essential.&lt;/p&gt;

&lt;p&gt;In this guide, I walk through practical SQL examples covering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating tables (DDL)&lt;/li&gt;
&lt;li&gt;Managing data (DML)&lt;/li&gt;
&lt;li&gt;Filtering and transforming query results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All examples are beginner-friendly and work well in PostgreSQL (and most relational databases).&lt;/p&gt;




&lt;h2&gt;
  
  
  DDL vs DML
&lt;/h2&gt;

&lt;h3&gt;
  
  
  DDL (Data Definition Language)
&lt;/h3&gt;

&lt;p&gt;DDL is used to define and manage the structure of database objects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Common commands: &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;ALTER&lt;/code&gt;, &lt;code&gt;DROP&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Affects the database schema&lt;/li&gt;
&lt;li&gt;Changes are typically permanent&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  DML (Data Manipulation Language)
&lt;/h3&gt;

&lt;p&gt;DML is used to interact with and manipulate data stored in tables.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Common commands: &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;, &lt;code&gt;SELECT&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Works within existing table structures&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Core SQL Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CREATE (DDL)
&lt;/h3&gt;

&lt;p&gt;Used to create a new table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  INSERT
&lt;/h3&gt;

&lt;p&gt;Adds new records into a table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'john@example.com'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  UPDATE
&lt;/h3&gt;

&lt;p&gt;Modifies existing records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; 
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'newemail@example.com'&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;⚠️ Always use a &lt;code&gt;WHERE&lt;/code&gt; clause unless you intend to update all rows.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  DELETE
&lt;/h3&gt;

&lt;p&gt;Removes records from a table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; 
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;⚠️ Omitting &lt;code&gt;WHERE&lt;/code&gt; will delete all rows in the table.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Filtering with WHERE
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;WHERE&lt;/code&gt; clause is used to filter records based on conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  IN / NOT IN
&lt;/h3&gt;

&lt;p&gt;Check if a value exists within a list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  LIKE
&lt;/h3&gt;

&lt;p&gt;Used for pattern matching in strings.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;%&lt;/code&gt; → matches zero or more characters&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_&lt;/code&gt; → matches a single character
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="s1"&gt;'J%'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;-- starts with J&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;ILIKE&lt;/span&gt; &lt;span class="s1"&gt;'%jo%'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;-- contains 'jo' (case-insensitive in PostgreSQL)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  BETWEEN
&lt;/h3&gt;

&lt;p&gt;Filters values within a range (inclusive).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;BETWEEN&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  CASE WHEN for Data Transformation
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;CASE WHEN&lt;/code&gt; allows you to apply conditional logic directly in SQL queries, similar to if-else statements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Categorizing Data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; 
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;CASE&lt;/span&gt; 
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Junior'&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Senior'&lt;/span&gt;
        &lt;span class="k"&gt;ELSE&lt;/span&gt; &lt;span class="s1"&gt;'Expert'&lt;/span&gt;
    &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="k"&gt;level&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example: Student Performance Classification
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;CASE&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Distinction'&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Merit'&lt;/span&gt;
        &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'Pass'&lt;/span&gt;
        &lt;span class="k"&gt;ELSE&lt;/span&gt; &lt;span class="s1"&gt;'Fail'&lt;/span&gt;
    &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;performance&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;exam_results&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps transform raw numeric data into meaningful categories.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding SQL fundamentals like DDL, DML, filtering, and conditional logic is key to working effectively with data.&lt;/p&gt;

&lt;p&gt;These building blocks will help you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structure databases&lt;/li&gt;
&lt;li&gt;Manage records efficiently&lt;/li&gt;
&lt;li&gt;Extract meaningful insights&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From here, you can explore more advanced topics like joins, aggregations, and indexing.&lt;/p&gt;




&lt;p&gt;💡 &lt;em&gt;Tip: Practice these queries in PostgreSQL or any SQL environment to reinforce your learning.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>beginners</category>
      <category>database</category>
      <category>postgres</category>
    </item>
  </channel>
</rss>
