<?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>DEV Community: Martin Ndungu</title>
    <description>The latest articles on DEV Community by Martin Ndungu (@martin_ndungu_38).</description>
    <link>https://dev.to/martin_ndungu_38</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%2F3820856%2Fbfbcbfa7-3ab5-46b1-995b-911a3fdcad9c.jpg</url>
      <title>DEV Community: Martin Ndungu</title>
      <link>https://dev.to/martin_ndungu_38</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/martin_ndungu_38"/>
    <language>en</language>
    <item>
      <title>Subqueries and Cte's</title>
      <dc:creator>Martin Ndungu</dc:creator>
      <pubDate>Tue, 21 Apr 2026 13:37:43 +0000</pubDate>
      <link>https://dev.to/martin_ndungu_38/subqueries-and-ctes-105b</link>
      <guid>https://dev.to/martin_ndungu_38/subqueries-and-ctes-105b</guid>
      <description>&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;SQL is a powerful language used for managing and analyzing data. As queries become more complex, tools like subqueries and Common Table Expressions (CTEs) help simplify logic and improve readability.&lt;/p&gt;

&lt;p&gt;What is a Subquery?&lt;/p&gt;

&lt;p&gt;A subquery is a query nested inside another query. It is used to perform operations that depend on the result of another query.&lt;/p&gt;

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

&lt;p&gt;SELECT name&lt;br&gt;
FROM customers&lt;br&gt;
WHERE customer_id IN (&lt;br&gt;
    SELECT customer_id FROM sales&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Types of Subqueries&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Scalar Subquery&lt;br&gt;
Returns a single value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multi-row Subquery&lt;br&gt;
Returns multiple rows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Correlated Subquery&lt;br&gt;
Depends on the outer query.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When to Use Subqueries&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filtering based on aggregated data&lt;/li&gt;
&lt;li&gt;Comparing values across tables&lt;/li&gt;
&lt;li&gt;Handling nested logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What is a CTE?&lt;/p&gt;

&lt;p&gt;A Common Table Expression (CTE) is a temporary result set defined using the WITH clause.&lt;/p&gt;

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

&lt;p&gt;WITH sales_data AS (&lt;br&gt;
    SELECT customer_id, SUM(amount) AS total&lt;br&gt;
    FROM sales&lt;br&gt;
    GROUP BY customer_id&lt;br&gt;
)&lt;br&gt;
SELECT * FROM sales_data;&lt;/p&gt;

&lt;p&gt;Types of CTEs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple CTE&lt;/li&gt;
&lt;li&gt;Recursive CTE (used for hierarchical data)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When to Use CTEs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When queries become complex&lt;/li&gt;
&lt;li&gt;When logic needs to be reused&lt;/li&gt;
&lt;li&gt;When readability is important&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Subqueries vs CTEs&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Subqueries&lt;/th&gt;
&lt;th&gt;CTEs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reusability&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Complexity Handling&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Excellent&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;p&gt;Both subqueries and CTEs are essential tools in SQL. Subqueries are useful for simple logic, while CTEs are ideal for complex and readable queries.&lt;/p&gt;

&lt;p&gt;Mastering both improves your ability to solve real-world data problems efficiently.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>sql</category>
      <category>postgres</category>
      <category>postgressql</category>
    </item>
    <item>
      <title>SQL JOINs Explained Simply – From Beginner to Data Analyst</title>
      <dc:creator>Martin Ndungu</dc:creator>
      <pubDate>Sun, 19 Apr 2026 19:40:40 +0000</pubDate>
      <link>https://dev.to/martin_ndungu_38/sql-joins-explained-simply-from-beginner-to-data-analyst-4jal</link>
      <guid>https://dev.to/martin_ndungu_38/sql-joins-explained-simply-from-beginner-to-data-analyst-4jal</guid>
      <description>&lt;p&gt;*&lt;em&gt;SQL JOINs Explained Simply – From Beginner to Data Analyst&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Introduction&lt;br&gt;
When I first started learning SQL, JOINs felt confusing and overwhelming. But once I understood how they work, everything changed. JOINs are one of the most powerful tools in SQL they allow you to combine data from multiple tables and unlock real insights.&lt;/p&gt;

&lt;p&gt;In this article, I’ll explain SQL JOINs in the simplest way possible using real examples from my project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a JOIN?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A JOIN is used to combine rows from two or more tables based on a related column.&lt;/p&gt;

&lt;p&gt;Think of it like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One table has &lt;strong&gt;students&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Another table has &lt;strong&gt;exam results&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A JOIN allows you to connect them and answer questions like:&lt;br&gt;
👉 &lt;em&gt;Which student scored what marks?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Types of SQL JOINs&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;INNER JOIN (Most Common)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns only matching records from both tables.&lt;/p&gt;

&lt;p&gt;Example:&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="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;diagnosis&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;
&lt;span class="k"&gt;INNER&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctors&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Only shows records where a match exists&lt;br&gt;
❌ Drops unmatched data&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;LEFT JOIN&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns ALL records from the left table and matching ones from the right.&lt;/p&gt;

&lt;p&gt;Example:&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="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;diagnosis&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Shows ALL patients&lt;br&gt;
✅ Even those without appointments&lt;/p&gt;



&lt;ol&gt;
&lt;li&gt;RIGHT JOIN&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Returns ALL records from the right table.&lt;/p&gt;

&lt;p&gt;Example:&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="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;doctor_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;patient_name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;RIGHT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctors&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doctor_id&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Shows ALL doctors&lt;br&gt;
✅ Even those who haven’t seen patients&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finding Missing Data (Advanced Trick)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Want to find patients who NEVER had appointments?&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="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;city&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patients&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;city_hospital&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointments&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; 
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;patient_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appointment_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔥 This is a very important real-world technique.&lt;/p&gt;




&lt;p&gt;Real-World Use Case&lt;/p&gt;

&lt;p&gt;Imagine a hospital system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Patients table → personal details&lt;/li&gt;
&lt;li&gt;Doctors table → medical staff&lt;/li&gt;
&lt;li&gt;Appointments table → interactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using JOINs, you can answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which doctor treated which patient?&lt;/li&gt;
&lt;li&gt;Which patients have never visited?&lt;/li&gt;
&lt;li&gt;What diagnoses were given?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly how data analysts work in real companies.&lt;/p&gt;

&lt;p&gt;Common Mistakes Beginners Make&lt;/p&gt;

&lt;p&gt;❌ Forgetting the ON condition&lt;br&gt;
❌ Joining wrong columns&lt;br&gt;
❌ Using INNER JOIN when LEFT JOIN is needed&lt;br&gt;
❌ Not understanding NULL results&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;INNER JOIN = matching records only&lt;/li&gt;
&lt;li&gt;LEFT JOIN = keep everything from left&lt;/li&gt;
&lt;li&gt;RIGHT JOIN = keep everything from right&lt;/li&gt;
&lt;li&gt;JOINs are essential for real data analysis&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;JOINs are not just a SQL topic — they are a core skill for data analysis, business intelligence, and real-world problem solving.&lt;/p&gt;

&lt;p&gt;Once you master JOINs, you move from writing queries to actually understanding data.&lt;/p&gt;

&lt;p&gt;About This Project&lt;/p&gt;

&lt;p&gt;This article is based on my SQL practice project using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;Real-world structured datasets&lt;/li&gt;
&lt;li&gt;Topics including JOINs, Window Functions, and Data Analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Connect With Me&lt;/p&gt;

&lt;p&gt;If you're also learning SQL or data analysis, feel free to connect and share ideas!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding Data Modeling in Power BI: Joins, Relationships, and Schemas Explained</title>
      <dc:creator>Martin Ndungu</dc:creator>
      <pubDate>Tue, 31 Mar 2026 17:15:39 +0000</pubDate>
      <link>https://dev.to/martin_ndungu_38/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-33ef</link>
      <guid>https://dev.to/martin_ndungu_38/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-33ef</guid>
      <description>&lt;p&gt;When I first started using Power BI, I was all about the visuals. I’d drag charts onto the canvas, tweak colors, and feel like I was building something impressive. But before long, things started going sideways numbers didn’t add up, filters acted strangely, and performance slowed to a crawl as my data grew.&lt;br&gt;
That’s when it clicked: the real foundation of a good Power BI report isn’t the visuals. It’s the data model sitting underneath.&lt;br&gt;
This article comes from that shift in perspective. I’ll walk through data modeling in a practical, down‑to‑earth way covering joins, relationships, schemas, and some of the common challenges you’ll run into.&lt;br&gt;
What Is Data Modeling, Really?&lt;br&gt;
Data modeling is simply the process of organizing your data so you can analyze it accurately and efficiently.&lt;br&gt;
In practice, that means splitting your data into logical tables and defining how they connect. Instead of jamming everything into one giant dataset, you build a system where each table has a clear job.&lt;br&gt;
Here’s how I think about it: if raw data is a messy pile of papers on your desk, data modeling is what happens when you sort those papers into labeled folders so you can actually find what you need.&lt;br&gt;
Understanding SQL Joins with Real Scenarios&lt;br&gt;
Before diving into Power BI relationships, it helps to understand joins. Joins are how you combine data from different tables, usually during data prep.&lt;br&gt;
Let’s say you have two tables: Customers (CustomerID, Name) and Orders (OrderID, CustomerID, Amount). Here’s how different joins play out in a real business context.&lt;br&gt;
INNER JOIN&lt;br&gt;
This returns only records that exist in both tables. If you run an inner join, you’ll see only customers who’ve actually placed an order. Anyone who signed up but never bought anything drops out. That makes this join great for analyzing active customers or confirmed transactions.&lt;br&gt;
LEFT JOIN &lt;br&gt;
A left join returns all records from the left table, plus matching ones from the right. If you start with Customers, you’ll see every customer including those with no orders. Their order fields will just show up blank. I’ve found this especially useful in marketing analysis, like when you want to spot registered users who haven’t converted yet.&lt;br&gt;
RIGHT JOIN&lt;br&gt;
Right join is the reverse it keeps everything in the right table. If you lead with Orders, you’ll see all orders, even if some are missing customer details. That’s handy for catching data quality issues, like incomplete records.&lt;/p&gt;

&lt;p&gt;FULL OUTER JOIN&lt;br&gt;
This grabs everything from both tables. You’ll get all customers and all orders, whether they match or not. I’ve used this most often in audits, when I need a complete picture of what’s there mismatches and all.&lt;br&gt;
LEFT ANTI JOIN&lt;br&gt;
This returns records from the left table that have no match in the right one. For example, it’ll show you customers who signed up but never bought anything. In practice, this kind of insight is gold for creating targeted campaigns or follow‑up promotions.&lt;br&gt;
RIGHT ANTI JOIN &lt;br&gt;
Similarly, this returns records from the right table with no match on the left. A typical use case is finding orders that aren’t tied to a valid customer. That usually signals something like a system error or bad data entry that needs fixing.&lt;br&gt;
Where Joins Happen in Power BI&lt;br&gt;
In Power BI, joins are handled in Power Query during the data preparation stage. Here’s how I usually do it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Click “Transform Data” to open Power Query&lt;/li&gt;
&lt;li&gt; Select your main table&lt;/li&gt;
&lt;li&gt; Click “Merge Queries”&lt;/li&gt;
&lt;li&gt; Choose the second table&lt;/li&gt;
&lt;li&gt; Select the matching columns (e.g., CustomerID)&lt;/li&gt;
&lt;li&gt; Pick your join type (Inner, Left, etc.)&lt;/li&gt;
&lt;li&gt; Expand the merged column to pull in the fields you need
At this point, you’re physically combining data into one table.
How Relationships Work in Power BI
Relationships are different. Instead of merging tables, they connect them while keeping them separate.
You define relationships in “Model View” or through “Manage Relationships”.
Types of Relationships
• One to Many
This is the workhorse of data modeling. One customer can have many orders. The Customer table holds unique CustomerIDs, while the Orders table may repeat them. Most business models are built around this structure.
• Many to Many
Both tables can have duplicates. Think of products and promotions: a product can belong to multiple promotions, and a promotion can include many products. In my experience, many‑to‑many relationships need careful handling they can easily throw off totals if you’re not deliberate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;• One to One&lt;br&gt;
Each value appears just once in both tables. It’s less common, but I’ve used it when splitting large tables for performance or security reasons.&lt;br&gt;
• Active vs Inactive Relationships&lt;br&gt;
Power BI lets you have multiple relationships between tables, but only one can be active at a time.&lt;br&gt;
An “active” relationship gets used automatically in calculations.&lt;br&gt;
An “inactive” one must be activated through DAX when needed.&lt;br&gt;
A good example: a sales table with both an Order Date and a Delivery Date. Depending on what you’re analyzing, you might need to switch between them.&lt;br&gt;
• Cardinality&lt;br&gt;&lt;br&gt;
Cardinality defines how tables relate one‑to‑many, many‑to‑one, or many‑to‑many. Getting this right matters because it directly impacts how filters behave and how your calculations turn out.&lt;br&gt;
• Cross Filter Direction &lt;br&gt;
This controls how filters move between tables. Single direction means filters flow one way only; both directions means filters move back and forth. I usually stick with single direction unless I have a clear reason to change it. Both directions can lead to confusing results and slower performance if you’re not careful.&lt;br&gt;
Joins vs Relationships: A Quick Comparison&lt;br&gt;
This distinction is important. Joins combine tables into one. They happen in Power Query, during data prep. Relationships connect tables without merging them. They happen in the Model View and shape how analysis works.&lt;br&gt;
Another way to think about it: joins shape the data before it’s loaded; relationships define how the data behaves after it’s loaded.&lt;br&gt;
• Fact and Dimension Tables&lt;br&gt;
A clean data model separates tables into two types. Fact tables hold measurable, numeric data sales, revenue, quantity. Dimension tables hold descriptive attributes customer names, product categories, dates.&lt;br&gt;
For example, in a sales model, you’d have one Sales fact table connected to Customer, Product, and Date dimension tables. This setup improves both performance and clarity.&lt;br&gt;
Data Modeling Schemas&lt;br&gt;
• Star Schema&lt;br&gt;
This is the go‑to approach. You have a central fact table connected directly to multiple dimension tables. In most of my projects, I start with a star schema because it’s simple, efficient, and easy to maintain.&lt;br&gt;
• Snowflake Schema &lt;br&gt;
Think of this as a more normalized version of a star schema. Here, dimension tables are broken down furtherfor example, splitting a Product table into Category and Subcategory tables. It reduces redundancy but adds complexity.&lt;br&gt;
• Flat Table&lt;br&gt;
Everything in one table. It’s quick to set up, but as your data grows, it becomes a bottleneck. I’d say flat tables are fine for small projects but best avoided once you start scaling.&lt;br&gt;
• Role‑Playing Dimensions&lt;br&gt;
Sometimes a single dimension table gets used in multiple ways. A classic example: one Date table used for Order Date, Shipping Date, and Delivery Date. Instead of duplicating the table, you create multiple relationships with different roles. It keeps the model clean while supporting flexible analysis.&lt;br&gt;
Common Data Modeling Challenges&lt;br&gt;
From experience, a few problems pop up again and again: overusing many‑to‑many relationships can mess up aggregations; skipping thorough data cleaning leads to unreliable results; incorrect cross filter direction creates confusing outputs; loading too many unnecessary tables slows performance. These aren’t just technical slip‑ups they directly affect the quality of insights.&lt;br&gt;
Personal Reflection&lt;br&gt;
Learning data modeling completely changed how I use Power BI. I don’t start with visuals anymore. I start by asking: how is the data structured? How should tables relate? I’ve also gotten more disciplined I double‑check relationships, validate totals, and think through how filters will behave.&lt;br&gt;
From a practical standpoint, this shift has made my reports more accurate, faster, and easier to explain.&lt;br&gt;
Final Thoughts&lt;br&gt;
Data modeling is the backbone of any solid Power BI solution. It ensures your numbers are correct, filters work as expected, and reports perform well. In my experience, taking the time to build a clean, thoughtful model always pays off fewer errors, clearer analysis, and more confidence in the results.&lt;br&gt;
If you’re serious about data analysis, mastering data modeling isn’t optional. It’s essential.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>data</category>
    </item>
    <item>
      <title>HOW EXCEL IS USED IN REAL-WORLD DATA ANALYSIS</title>
      <dc:creator>Martin Ndungu</dc:creator>
      <pubDate>Tue, 31 Mar 2026 17:10:21 +0000</pubDate>
      <link>https://dev.to/martin_ndungu_38/how-excel-is-used-in-real-world-data-analysis-4dj0</link>
      <guid>https://dev.to/martin_ndungu_38/how-excel-is-used-in-real-world-data-analysis-4dj0</guid>
      <description>&lt;p&gt;When I first started using Excel, I honestly thought it was just a digital grid for typing in numbers and maybe doing a little addition. But the more I worked with it, the more I realized it’s actually one of the most powerful tools in real-world data analysis.&lt;br&gt;
These days, you’ll find Excel everywhere in finance, business, healthcare, logistics, even small startups. It’s often what people use to make decisions based on data. What surprised me most was how something that looks so simple on the surface can completely change the way you understand information and raw data.&lt;br&gt;
So, What Is Excel, Really?&lt;br&gt;
At its core, Excel is a spreadsheet that organizes data into rows and columns. But beyond that, it helps you clean up messy data, spot patterns, and present insights in a way that actually makes sense. Instead of just staring at numbers, you start answering questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  What’s happening?&lt;/li&gt;
&lt;li&gt;  Why is it happening?&lt;/li&gt;
&lt;li&gt;  What should we do next?
How Excel Gets Used in Practice
As I’ve been practicing especially with datasets like product analysis, I’ve started to see how Excel really works in real-life situations. Examples of this are;&lt;/li&gt;
&lt;li&gt;Cleaning Messy Data
In the real world, data almost never comes clean. You don’t just open a file and start analyzing. There’s always something off:&lt;/li&gt;
&lt;li&gt;  Prices written as "KSh 1,200"&lt;/li&gt;
&lt;li&gt;  Ratings like "4.5 out of 5"&lt;/li&gt;
&lt;li&gt;  Discounts shown as "25%"&lt;/li&gt;
&lt;li&gt;  Missing entries or duplicates
I used to overlook how important cleaning was. Now I know that this step is the foundation of any good analysis. With tools like Find and Replace, or functions like SUBSTITUTE, VALUE, and TRIM, I’ve learned to turn messy text into usable numbers. That alone changed how I approach any new dataset.&lt;/li&gt;
&lt;li&gt;Turning Raw Data into Useful Information
Once the data is clean, the next step is making it meaningful.
Instead of just looking at prices, I started calculating things like discount amounts, average prices, and total reviews. Using formulas like IF to group data into categories like "High" or "Low," or ABS to clean up negative values, I realized that analysis isn’t just about reading data it’s about transforming it into something more useful.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Pivot Tables Changed Everything
Pivot tables completely shifted how I use Excel. Instead of manually sorting and calculating, I could summarize large datasets in seconds, find top performing products, or compare categories at a glance.
Want to know which products have the most reviews? Which have the highest discounts? How ratings are distributed? Pivot tables answer that in a few clicks. Before this, I didn’t think Excel could handle that kind of analysis so easily.&lt;/li&gt;
&lt;li&gt;Visualizing the Story
Numbers alone can be hard to follow. But when you turn them into charts, patterns start to pop out.
Using bar charts, pie charts, or slicers, I could see things like whether higher discounts actually led to more reviews, or if better ratings attracted more engagement. That’s when data starts to tell a story.&lt;/li&gt;
&lt;li&gt;Bringing It All Together with Dashboards
One of the most exciting parts for me has been building dashboards. A good dashboard pulls everything into one place: key metrics, charts, filters, slicers. Instead of digging through rows of data, you can look at one screen and immediately understand what’s going on. This is exactly how businesses track performance in real life.
Where Excel Fits in the Real World
Now that I’ve gotten deeper into Excel, I see how it’s used across different fields:&lt;/li&gt;
&lt;li&gt;  Finance: tracking budgets, expenses, profits&lt;/li&gt;
&lt;li&gt;  Business: analyzing product performance and customer behavior&lt;/li&gt;
&lt;li&gt;  Marketing: measuring campaign results&lt;/li&gt;
&lt;li&gt;  Operations: managing inventory and logistics
This isn’t just theory. This is what people actually do day to day.
How It’s Changed My Thinking
Learning Excel has really shifted my mindset. Before, data felt like a bunch of numbers with no real meaning. Now, I see it as something that can answer questions and guide decisions. I’ve become more analytical, instead of guessing, I look for evidence in the data. I’ve also learned to be more careful, especially with cleaning, because small mistakes can lead to wrong conclusions.
Most importantly, Excel gave me confidence. I feel like I can take any dataset, make sense of it, and pull out a complete and useful insights.
Final Thoughts
Excel is more than a spreadsheet. It’s a practical, hands-on way to understand the world through data. Whether you’re in finance, running a business, or working on a personal project, it gives you the power to turn raw numbers into real insights.
For me, learning Excel was the first big step into data analysis and it’s a skill I know I’ll keep building on.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>learning</category>
      <category>devops</category>
      <category>datascience</category>
      <category>datastructures</category>
    </item>
  </channel>
</rss>
