<?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: Victor Karanja</title>
    <description>The latest articles on Forem by Victor Karanja (@victak36lgtm).</description>
    <link>https://forem.com/victak36lgtm</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%2F3708651%2Fd2e66539-b7bd-4a09-b578-106fcec24dea.jpeg</url>
      <title>Forem: Victor Karanja</title>
      <link>https://forem.com/victak36lgtm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/victak36lgtm"/>
    <language>en</language>
    <item>
      <title>Understanding SQL: DDL, DML, and Data Transformation</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Fri, 24 Apr 2026 04:59:22 +0000</pubDate>
      <link>https://forem.com/victak36lgtm/-understanding-sql-ddl-dml-and-data-transformation-3hkh</link>
      <guid>https://forem.com/victak36lgtm/-understanding-sql-ddl-dml-and-data-transformation-3hkh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Structured Query Language (SQL) is the standard language for managing and manipulating relational databases.&lt;/p&gt;

&lt;p&gt;This article explores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Definition Language (DDL)&lt;/li&gt;
&lt;li&gt;Data Manipulation Language (DML)&lt;/li&gt;
&lt;li&gt;Filtering with WHERE&lt;/li&gt;
&lt;li&gt;Conditional logic using CASE WHEN&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Are DDL and DML?
&lt;/h2&gt;

&lt;p&gt;SQL commands are broadly categorized into two groups: &lt;strong&gt;DDL&lt;/strong&gt; and &lt;strong&gt;DML&lt;/strong&gt;.&lt;/p&gt;

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

&lt;p&gt;DDL commands define and modify the &lt;strong&gt;structure&lt;/strong&gt; of database objects. They shape of your database—creating tables, altering columns, and removing schemas. DDL operations take effect immediately and permanently.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CREATE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Build new database objects (schemas, tables, columns)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ALTER&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify existing structures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DROP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delete objects entirely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;RENAME&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Change object names&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;p&gt;DML commands manage the &lt;strong&gt;data inside&lt;/strong&gt; tables, adding rows, updating values, and deleting records. Unlike DDL, DML changes can be rolled back using transactions if something goes wrong.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;INSERT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add new rows to a table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;UPDATE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify existing data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DELETE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Remove specific rows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieve data (sometimes classified as DQL)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The Key Difference
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;DDL&lt;/th&gt;
&lt;th&gt;DML&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Focus&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Structure&lt;/td&gt;
&lt;td&gt;Data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Commands&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;ALTER&lt;/code&gt;, &lt;code&gt;DROP&lt;/code&gt;, &lt;code&gt;RENAME&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&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;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reversibility&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Permanent (auto-commit)&lt;/td&gt;
&lt;td&gt;Can be rolled back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Adding a new column&lt;/td&gt;
&lt;td&gt;Changing a student's grade&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  DDL in Action: Building the Nairobi Academy Database
&lt;/h2&gt;

&lt;p&gt;In the Nairobi Academy assignment, DDL commands established the entire database framework from scratch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the Schema and Tables
&lt;/h3&gt;

&lt;p&gt;The first step was creating a dedicated schema to organize all school-related tables:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sql
CREATE SCHEMA nairobi_academy;
SET search_path TO nairobi_academy;
Then three tables were built using CREATE TABLE:
sql
-- Students table stores pupil information
CREATE TABLE students (
    student_id SERIAL PRIMARY KEY,
    first_name VARCHAR(50) NOT NULL,
    last_name VARCHAR(50) NOT NULL,
    gender CHAR(1) CHECK (gender IN ('M', 'F')),
    class VARCHAR(20),
    city VARCHAR(50),
    date_of_birth DATE
);

-- Subjects table stores courses offered
CREATE TABLE subjects (
    subject_id SERIAL PRIMARY KEY,
    subject_name VARCHAR(100) NOT NULL,
    department VARCHAR(50),
    credits INTEGER
);

-- Exam_results links students to their scores
CREATE TABLE exam_results (
    result_id SERIAL PRIMARY KEY,
    student_id INTEGER REFERENCES students(student_id),
    subject_id INTEGER REFERENCES subjects(subject_id),
    marks INTEGER CHECK (marks &amp;gt;= 0 AND marks &amp;lt;= 100),
    exam_date DATE
);
Modifying Structure with ALTER
Real-world databases evolve. When the school forgot to include phone numbers, ALTER TABLE resolved it:
sql
Copy
ALTER TABLE students ADD COLUMN phone_number VARCHAR(20);
Later, the credits column needed clearer naming:
sql

ALTER TABLE subjects RENAME COLUMN credits TO credit_hours;
When the requirement changed again, the column was removed:
sql

ALTER TABLE students DROP COLUMN phone_number;
These ALTER operations demonstrate DDL's flexibility—structures adapt without rebuilding everything.
DML in Action: Populating and Managing Data
Once tables existed, DML commands brought them to life with real student records.
INSERT: Adding Data
Ten students, ten subjects, and ten exam results were inserted:
sql

INSERT INTO students (first_name, last_name, gender, class, city, date_of_birth) 
VALUES ('James', 'Mwangi', 'M', 'Form 4', 'Nairobi', '2006-03-15');
The INSERT statement follows a clear pattern: specify the table, list columns, then provide values in matching order. Bulk inserts use comma-separated value sets.
UPDATE: Correcting Data
When Esther Akinyi moved from Nakuru to Nairobi, UPDATE reflected this change:

sql
UPDATE students 
SET city = 'Nairobi' 
WHERE student_id = 5;
A marks entry error was also fixed:

sql

UPDATE exam_results 
SET marks = 59 
WHERE result_id = 5;
Critical rule: Always use WHERE with UPDATE. Without it, every row changes.
DELETE: Removing Data
When an exam was cancelled, DELETE removed it cleanly:
sql

DELETE FROM exam_results 
WHERE result_id = 9;
Again, WHERE is essential—omitting it empties the entire table.
Filtering Data with WHERE
The WHERE clause is SQL's gatekeeper. It filters rows based on conditions, ensuring queries return only relevant data.
Basic Comparison Operators
Table
Operator    Meaning Example
=   Equal to    WHERE class = 'Form 4'
&amp;gt;   Greater than    WHERE marks &amp;gt; 70
&amp;lt;   Less than   WHERE marks &amp;lt; 40
&amp;gt;=  Greater than or equal   WHERE marks &amp;gt;= 70
&amp;lt;=  Less than or equal  WHERE marks &amp;lt;= 50
&amp;lt;&amp;gt; or !=    Not equal   WHERE city &amp;lt;&amp;gt; 'Nairobi'
Logical Operators
Combine conditions with AND and OR:

sql
-- Form 3 students from Nairobi (both conditions must be true)
SELECT * FROM students WHERE class = 'Form 3' AND city = 'Nairobi';

-- Students in Form 2 or Form 4 (either condition can be true)
SELECT * FROM students WHERE class = 'Form 2' OR class = 'Form 4';
Special Operators
BETWEEN checks ranges inclusively:

sql
-- Marks from 50 to 80, including both endpoints
SELECT * FROM exam_results WHERE marks BETWEEN 50 AND 80;
IN checks membership in a list:

sql

-- Students in any of these three cities
SELECT * FROM students WHERE city IN ('Nairobi', 'Mombasa', 'Kisumu');
N IN excludes values:

sql

-- Students in Form 1 or Form 4 only
SELECT * FROM students WHERE class NOT IN ('Form 2', 'Form 3');

LIKE enables pattern matching with wildcards:
Table
Pattern Matches
'A%'    Starts with 'A'
'%Studies%' Contains 'Studies' anywhere
'_a%'   Second letter is 'a'

sql

-- First names starting with A or E
SELECT * FROM students 
WHERE first_name LIKE 'A%' OR first_name LIKE 'E%';
Transforming Data with CASE WHEN
Raw data often needs interpretation before it becomes useful. CASE WHEN acts as SQL's if-then-else logic, creating new calculated columns based on conditions.
Grading Exam Results
Instead of displaying raw marks, the assignment labeled each score with a performance grade:
sql

SELECT 
    result_id,
    marks,
    CASE 
        WHEN marks &amp;gt;= 80 THEN 'Distinction'
        WHEN marks &amp;gt;= 60 THEN 'Merit'
        WHEN marks &amp;gt;= 40 THEN 'Pass'
        ELSE 'Fail'
    END AS performance
FROM exam_results;
SQL evaluates conditions top to bottom. A mark of 85 hits the first condition (&amp;gt;= 80) and becomes "Distinction"—it never reaches the &amp;gt;= 60 check. This ordering is crucial.
Categorizing Students
Students were grouped into academic levels:
sql

SELECT 
    first_name,
    last_name,
    class,
    CASE 
        WHEN class IN ('Form 3', 'Form 4') THEN 'Senior'
        WHEN class IN ('Form 1', 'Form 2') THEN 'Junior'
    END AS student level
FROM students;
Every CASE must end with END, and AS names the new column.    

Inconclusion, DDL builds the container, while DML fills and shapes the content. The Nairobi Academy data, demonstrated this relationship—CREATE and ALTER established tables, then INSERT, UPDATE, and DELETE managed student records. Filtering with WHERE and operators like BETWEEN, IN, and LIKE narrowed results to specific needs. Finally, CASE WHEN transformed numerical marks into meaningful categories, proving that SQL is not just about storing data—it's about making data understandable.
Mastering these basics prepares you for;
*joins
*windows functions
*Query optimization
*subqueries.
 In SQL real understanding comes from writing queries and lots of practice.


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Unlocking Insights: Transforming Messy Data Into Action Using Power BI</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Mon, 09 Feb 2026 06:37:03 +0000</pubDate>
      <link>https://forem.com/victak36lgtm/unlocking-insights-transforming-messy-data-into-action-using-power-bi-3lnn</link>
      <guid>https://forem.com/victak36lgtm/unlocking-insights-transforming-messy-data-into-action-using-power-bi-3lnn</guid>
      <description>&lt;ol&gt;
&lt;li&gt;
## How Analysts Clean Messy Data, Use DAX, and Build Dashboards Using Power BI
Power BI is an intelligent tool that helps organizations visualize and analyze their data. Raw day-to-day data can be messy and unfiltered. Analysts often deal with missing values, inconsistent formats, duplicates, and poorly structured tables. Power BI stands out because it allows analysts to clean, model, analyze, and visualize data. This article explains how analysts transform messy data into meaningful insights.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cleaning Messy Data with Power Query
&lt;/h2&gt;

&lt;p&gt;After loading your dataset, open &lt;em&gt;transform data&lt;/em&gt; to access the Power Query Editor.&lt;/p&gt;

&lt;h3&gt;
  
  
  common data problems
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Duplicate records- Inconsistent text (e.g.  'cardiology' 'cardio dep' 'Cardiolgy')
&lt;/li&gt;
&lt;li&gt;Numbers stored as text
&lt;/li&gt;
&lt;li&gt;Multiple values in a single column
&lt;/li&gt;
&lt;li&gt;Inconsistent date form&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of the common Power query Transformation are:&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Data Problems
&lt;/h2&gt;

&lt;p&gt;Real-world datasets are rarely perfect. Analysts often encounter the following data issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing values (nulls or blanks)&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Inconsistent text values (cardiology, Cardiology, Cardiology dept)&lt;/li&gt;
&lt;li&gt;Incorrect data types (numbers stored as text)&lt;/li&gt;
&lt;li&gt;Inconsistent date formats&lt;/li&gt;
&lt;li&gt;Spelling errors and typos&lt;/li&gt;
&lt;li&gt;Extra spaces or hidden characters&lt;/li&gt;
&lt;li&gt;Multiple values stored in a single column&lt;/li&gt;
&lt;li&gt;Inconsistent units of measurement&lt;/li&gt;
&lt;li&gt;Outliers and extreme values&lt;/li&gt;
&lt;li&gt;Poorly structured tables&lt;/li&gt;
&lt;li&gt;Mismatched keys between tables&lt;/li&gt;
&lt;li&gt;Changing data definitions over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Addressing these problems during data preparation ensures accurate analysis, reliable dashboards, and trustworthy business insights.&lt;/p&gt;

&lt;p&gt;Power Query automatically records every step, so you can modify your transformation at any time.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧩 Understanding Data Modelling in Power BI
&lt;/h2&gt;

&lt;p&gt;Before you start writing DAX, it’s important to understand data modelling. A data model is simply the way your tables connect inside Power BI. Think of it as the “map” that tells Power BI how your data fits together.&lt;/p&gt;

&lt;p&gt;A good data model usually includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fact tables&lt;/strong&gt; – contain numbers you want to analyze (sales, revenue, quantities).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dimension tables&lt;/strong&gt; – contain descriptive information (dates, products, customers).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships&lt;/strong&gt; – links between tables that allow Power BI to filter and calculate correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A clean model makes your reports faster, your calculations easier, and your DAX formulas more accurate.&lt;/p&gt;

&lt;p&gt;Once your data model is organized, you can start adding DAX logic to create measures, calculations, and business rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Data Analysis Expressions(&lt;em&gt;DAX)&lt;/em&gt; To create Business Logic
&lt;/h2&gt;

&lt;p&gt;With a clean data we use &lt;em&gt;dax&lt;/em&gt; to create calculations questions. &lt;br&gt;
Dax is used for:&lt;br&gt;
-conditional logic &lt;br&gt;
-time intelligence&lt;br&gt;
-Measures ratios and percentages&lt;/p&gt;

&lt;p&gt;Examples of &lt;strong&gt;Dax&lt;/strong&gt; measure&lt;br&gt;
Total Sales =&lt;br&gt;
SUM(Fact Sales[Sales Amount])&lt;/p&gt;

&lt;p&gt;Sales Growth =&lt;br&gt;
DIVIDE([Total Sales] - [Last Year Sales], [Last Year Sales])&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Simple and Clean Dashboards
&lt;/h2&gt;

&lt;p&gt;An effective dashboard presents only the most important metrics, allowing users to understand insights at a glance without being overwhelmed by unnecessary visuals. By prioritizing key KPIs, using consistent layouts analysts create dashboards that are intuitive, easy to navigate, and focused on actionable insights. &lt;/p&gt;

&lt;p&gt;Common Power BI visuals are like;&lt;/p&gt;

&lt;p&gt;-Bar graphs and column chats&lt;/p&gt;

&lt;p&gt;-Line charts for trends&lt;/p&gt;

&lt;p&gt;-KPI cards&lt;/p&gt;

&lt;p&gt;-Tables and matrices for detail&lt;/p&gt;

&lt;p&gt;-Maps for geographic analysis&lt;/p&gt;

&lt;p&gt;Using Power Query to clean and &lt;strong&gt;Dax&lt;/strong&gt;, adding logic to data you can transform raw data into meaningful insights.&lt;/p&gt;

&lt;p&gt;Inconclusion cleaning and preparing data is the basic foundation of every Insightful &lt;strong&gt;Power BI&lt;/strong&gt; . When you build a clear data model and choose the rightful visuals, your dashboards become intuitive data or report. &lt;/p&gt;

</description>
      <category>powerbi</category>
      <category>tutorial</category>
      <category>begginer</category>
    </item>
    <item>
      <title>#Schemas and Data Modelling in Power BI</title>
      <dc:creator>Victor Karanja</dc:creator>
      <pubDate>Sun, 01 Feb 2026 22:01:17 +0000</pubDate>
      <link>https://forem.com/victak36lgtm/schemas-and-data-modelling-in-power-bi-1ad9</link>
      <guid>https://forem.com/victak36lgtm/schemas-and-data-modelling-in-power-bi-1ad9</guid>
      <description>&lt;h2&gt;
  
  
  Schemas and Data Modelling in Power BI
&lt;/h2&gt;

&lt;p&gt;Data modelling is one of the most important steps in Power BI. A well-designed data model improves performance, accuracy, and ease to analyse, while a poor model can lead to slow reports and incorrect insights.&lt;/p&gt;

&lt;p&gt;This article explains schemas and data modelling concepts in Power BI.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Data Modelling?
&lt;/h2&gt;

&lt;p&gt;Data Modelling involves organizing data sources into a structured model. In Power BI, this means organizing tables and defining relationships between them to support accurate reporting and efficient calculations.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Schema?
&lt;/h2&gt;

&lt;p&gt;A schema is the structure and organization of data in a table. It's the logical arrangement of tables used in reports on Power BI.&lt;/p&gt;

&lt;p&gt;In Power BI, schemas help determine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How data is connected&lt;/li&gt;
&lt;li&gt;How filters flow between tables&lt;/li&gt;
&lt;li&gt;How efficiently queries are executed. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;****Types of schemas in Power BI.&lt;/p&gt;

&lt;p&gt;-Galaxy schema&lt;br&gt;
-Snowflakes schema&lt;br&gt;
-star schema&lt;/p&gt;

&lt;h2&gt;
  
  
  Snowflakes schema
&lt;/h2&gt;

&lt;p&gt;Here dimensions are split into sub dimensions, that can also be split into further smaller tables. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzf3acrco6ua0tqlb8j33.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzf3acrco6ua0tqlb8j33.jpg" alt="_snowflake diagram_" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Star schema&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;It's the mostly schema used in Excel, where it has multiple dimensions and one fact table.&lt;br&gt;
its advantages are; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster query performance&lt;/li&gt;
&lt;li&gt;Easier to write DAX formulas&lt;/li&gt;
&lt;li&gt;Better filter
-Easy to understand.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hcmxfxrx8y4hbcc9bll.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hcmxfxrx8y4hbcc9bll.png" alt="_star schema image_" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fact Tables
&lt;/h2&gt;

&lt;p&gt;A fact table stores quantitative data (measures) that can be analysed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics of Fact Tables:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contain numerical values&lt;/li&gt;
&lt;li&gt;Have many rows&lt;/li&gt;
&lt;li&gt;Reference dimension tables using keys&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Costomer Id&lt;/li&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;Age&lt;/li&gt;
&lt;li&gt;Region&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Dimension Tables
&lt;/h2&gt;

&lt;p&gt;A dimension table contains descriptive information that provides context to facts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics of Dimension Tables:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contain text or categorical data&lt;/li&gt;
&lt;li&gt;Have fewer rows than fact tables&lt;/li&gt;
&lt;li&gt;Used for filtering and grouping data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Product&lt;/li&gt;
&lt;li&gt;Customer ID&lt;/li&gt;
&lt;li&gt;Location&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Is a Relationship in Power BI?
&lt;/h2&gt;

&lt;p&gt;A relationship connects a column in one table to a column in another table, usually through a key.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sales[ProductID] → Product[ProductID]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows Power BI to understand how records relate across tables.&lt;/p&gt;




&lt;h2&gt;
  
  
  Relationship Types in Power BI
&lt;/h2&gt;

&lt;h3&gt;
  
  
  One-to-Many
&lt;/h3&gt;

&lt;p&gt;This is the most common and recommended relationship type.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One record in a dimension table&lt;/li&gt;
&lt;li&gt;Many matching records in a fact table&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One product → many sales records&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Used in star schemas.&lt;/p&gt;




&lt;h3&gt;
  
  
  Many-to-Many (&lt;em&gt;:&lt;/em&gt;)
&lt;/h3&gt;

&lt;p&gt;Occurs when both tables contain duplicate values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can cause ambiguous results&lt;/li&gt;
&lt;li&gt;Should be avoided when possible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use only when necessary and with caution.&lt;/p&gt;




&lt;h3&gt;
  
  
  One-to-One (1:1)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each value appears once in both tables&lt;/li&gt;
&lt;li&gt;Rarely used in analytical models&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Relationship Direction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Single Direction (Recommended)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Filters flow from dimension tables to fact tables&lt;/li&gt;
&lt;li&gt;Predictable and efficient behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Best practice for star schemas.&lt;/p&gt;




&lt;h3&gt;
  
  
  Both Direction (Bi-Directional)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Filters flow both ways&lt;/li&gt;
&lt;li&gt;Can cause confusion and performance issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use only when absolutely necessary.&lt;/p&gt;




&lt;h2&gt;
  
  
  Relationships in Star Schema
&lt;/h2&gt;

&lt;p&gt;In a star schema:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All dimension tables connect directly to the fact table&lt;/li&gt;
&lt;li&gt;Relationships are one-to-many&lt;/li&gt;
&lt;li&gt;Filter direction is single&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This results in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster performance&lt;/li&gt;
&lt;li&gt;Simpler DAX formulas&lt;/li&gt;
&lt;li&gt;Accurate filtering&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Relationships in Snowflake Schema
&lt;/h2&gt;

&lt;p&gt;In a snowflake schema:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dimension tables connect to other dimension tables&lt;/li&gt;
&lt;li&gt;More relationships are required&lt;/li&gt;
&lt;li&gt;More joins occur during queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce performance in Power BI&lt;/li&gt;
&lt;li&gt;Complicate filter behavior&lt;/li&gt;
&lt;li&gt;Make DAX harder to write and maintain&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Correct relationships:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure accurate calculations&lt;/li&gt;
&lt;li&gt;Control how filters behave&lt;/li&gt;
&lt;li&gt;Improve report performance&lt;/li&gt;
&lt;li&gt;Prevent incorrect totals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Poor relationships can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incorrect results&lt;/li&gt;
&lt;li&gt;Slow visuals&lt;/li&gt;
&lt;li&gt;Broken slicers and filters&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Best Practices for Power BI Relationships
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use star schema whenever possible&lt;/li&gt;
&lt;li&gt;Keep relationships one-to-many&lt;/li&gt;
&lt;li&gt;Use single-direction filtering&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Avoid many-to-many relationships
&lt;/h2&gt;

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

&lt;p&gt;Good data modelling is the foundation of effective Power BI reporting. By using well-structured schemas such as the star and snowflake schema and defining correct relationships, you can improve performance, ensure accurate calculations, and create reports that are easy to understand and maintain. Investing time in proper modelling leads to faster insights and more reliable decision-making.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
