<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amit Nishad on Medium]]></title>
        <description><![CDATA[Stories by Amit Nishad on Medium]]></description>
        <link>https://medium.com/@amit.nishad9652?source=rss-51094fd1f377------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ljc90oXKnG9Fo0rj</url>
            <title>Stories by Amit Nishad on Medium</title>
            <link>https://medium.com/@amit.nishad9652?source=rss-51094fd1f377------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:05:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amit.nishad9652/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Cleaning in SQL: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@amit.nishad9652/data-cleaning-in-sql-a-step-by-step-guide-c2cb23aa4f0b?source=rss-51094fd1f377------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2cb23aa4f0b</guid>
            <dc:creator><![CDATA[Amit Nishad]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 11:35:14 GMT</pubDate>
            <atom:updated>2025-03-21T11:35:14.116Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5U4WSXtulIaYBKny.png" /></figure><blockquote>Data cleaning is a crucial process in data management and analysis. Raw data is often messy, containing duplicates, missing values, inconsistent formats, and outliers. If data is not cleaned properly, it can lead to incorrect insights and poor decision-making. SQL (Structured Query Language) is a powerful tool that helps clean and prepare data efficiently.</blockquote><blockquote>In this blog, we will explore step-by-step SQL techniques to clean data, ensuring accuracy and consistency.</blockquote><h3>1. Identifying and Removing Duplicates</h3><h3>Why Remove Duplicates?</h3><blockquote>Duplicate records can arise due to multiple data entries, system errors, or data integration from different sources. Keeping only unique records ensures data accuracy.</blockquote><h3>How to Find Duplicates</h3><blockquote>To check for duplicate entries in a table, use:</blockquote><pre>SELECT email, COUNT(*) <br>FROM customers <br>GROUP BY email <br>HAVING COUNT(*) &gt; 1;</pre><blockquote>This query identifies records with the same email appearing more than once.</blockquote><h3>Removing Duplicates</h3><blockquote>To remove duplicate rows while keeping only one unique entry:</blockquote><pre>DELETE FROM customers <br>WHERE id NOT IN (<br>    SELECT MIN(id) FROM customers GROUP BY email<br>);</pre><blockquote>This keeps the record with the lowest id and removes others.</blockquote><blockquote>Alternatively, use DISTINCT when selecting data:</blockquote><pre>SELECT DISTINCT * FROM customers;</pre><h3>2. Handling Missing Values</h3><h3>Why Handle Missing Values?</h3><blockquote>Missing data can cause inaccurate analysis. SQL provides methods to replace, remove, or fill missing values.</blockquote><h3>Finding Missing Values</h3><blockquote>To check for NULL values in a column:</blockquote><pre>SELECT * FROM employees WHERE salary IS NULL;</pre><h3>Replacing Missing Values</h3><blockquote>If a salary column has missing values, we can replace them with a default value:</blockquote><pre>UPDATE employees <br>SET salary = 30000 <br>WHERE salary IS NULL;</pre><blockquote>Alternatively, while selecting data, we can replace NULL values dynamically:</blockquote><pre>SELECT id, name, COALESCE(salary, 30000) AS salary FROM employees;</pre><blockquote>Here, COALESCE() replaces NULL with 30000.</blockquote><blockquote>To replace NULL with the column’s average:</blockquote><pre>UPDATE employees <br>SET salary = (SELECT AVG(salary) FROM employees) <br>WHERE salary IS NULL;</pre><h3>3. Standardizing Data Formats</h3><h3>Why Standardize Data Formats?</h3><blockquote>Inconsistent formats make queries unreliable. SQL helps standardize text, dates, and numbers.</blockquote><h3>Standardizing Text Case</h3><blockquote>Convert names to <strong>Proper Case</strong>:</blockquote><pre>SELECT id, INITCAP(name) AS formatted_name FROM customers;</pre><blockquote>Convert text to <strong>Lower Case</strong>:</blockquote><pre>UPDATE customers <br>SET email = LOWER(email);</pre><blockquote>Convert text to <strong>Upper Case</strong>:</blockquote><pre>UPDATE customers <br>SET department = UPPER(department);</pre><h3>Standardizing Date Formats</h3><blockquote>Convert dates to a uniform format:</blockquote><pre>SELECT id, TO_CHAR(date_of_birth, &#39;YYYY-MM-DD&#39;) FROM users;</pre><blockquote>Convert VARCHAR to DATE:</blockquote><pre>UPDATE orders <br>SET order_date = TO_DATE(order_date, &#39;MM-DD-YYYY&#39;);</pre><h3>Cleaning Phone Numbers</h3><blockquote>Ensure all phone numbers have only digits:</blockquote><pre>UPDATE customers <br>SET phone = REGEXP_REPLACE(phone, &#39;[^0-9]&#39;, &#39;&#39;, &#39;g&#39;);</pre><blockquote>This removes non-numeric characters.</blockquote><h3>4. Removing Outliers</h3><h3>Why Remove Outliers?</h3><blockquote>Outliers are extreme values that distort analysis. They can be removed using statistical methods like the <strong>Interquartile Range (IQR)</strong>.</blockquote><h3>Identifying Outliers</h3><blockquote>Find outliers in salary:</blockquote><pre>SELECT * FROM employees <br>WHERE salary &lt; (SELECT PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY salary) FROM employees) <br>   OR salary &gt; (SELECT PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY salary) FROM employees);</pre><h3>Removing Outliers</h3><blockquote>Remove salaries below 20000 and above 150000:</blockquote><pre>DELETE FROM employees WHERE salary &lt; 20000 OR salary &gt; 150000;</pre><h3>5. Correcting Data Entry Errors</h3><h3>Why Fix Data Entry Errors?</h3><blockquote>Typos and incorrect values cause inconsistencies in reports and analysis.</blockquote><h3>Fixing Spelling Mistakes</h3><blockquote>Correct a wrongly spelled department:</blockquote><pre>UPDATE employees <br>SET department = &#39;Finance&#39; <br>WHERE department = &#39;Finanace&#39;;</pre><h3>Finding Incorrectly Formatted Emails</h3><pre>SELECT * FROM users WHERE email NOT LIKE &#39;%@%.com&#39;;</pre><blockquote>This finds emails that don’t follow the standard format.</blockquote><h3>6. Handling Extra Spaces and Inconsistent Casing</h3><h3>Why Trim Spaces?</h3><blockquote>Extra spaces in names or addresses cause mismatches in joins and queries.</blockquote><h3>Removing Extra Spaces</h3><blockquote>Trim leading and trailing spaces:</blockquote><pre>UPDATE customers <br>SET name = TRIM(BOTH &#39; &#39; FROM name);</pre><blockquote>Replace multiple spaces with a single space:</blockquote><pre>UPDATE customers <br>SET name = REGEXP_REPLACE(name, &#39;\s+&#39;, &#39; &#39;);</pre><blockquote>Convert email to lowercase to ensure consistency:</blockquote><pre>UPDATE customers <br>SET email = LOWER(email);</pre><h3>7. Standardizing Data for Joins</h3><h3>Why Standardize for Joins?</h3><blockquote>Mismatches occur when data has different formats (e.g., customer_id is VARCHAR in one table and INT in another).</blockquote><blockquote>Convert text-based IDs to integers:</blockquote><pre>UPDATE orders <br>SET customer_id = CAST(customer_id AS INT);</pre><blockquote>Trim leading zeros from IDs:</blockquote><pre>UPDATE orders <br>SET customer_id = LTRIM(customer_id, &#39;0&#39;);</pre><h3>Conclusion</h3><blockquote>Data cleaning is an essential process to ensure the accuracy and reliability of data. By applying these SQL techniques, you can:</blockquote><blockquote>Remove duplicates</blockquote><blockquote>Handle missing values</blockquote><blockquote>Standardize data formats</blockquote><blockquote>Identify and remove outliers</blockquote><blockquote>Fix data entry errors</blockquote><blockquote>Trim unnecessary spaces</blockquote><blockquote>Mastering these SQL techniques will help you work with clean, structured, and high-quality data, making your analysis more accurate and valuable.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2cb23aa4f0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ACID Properties in DBMS: A Complete Guide for Beginners]]></title>
            <link>https://medium.com/@amit.nishad9652/acid-properties-in-dbms-a-complete-guide-for-beginners-debf2d9bf713?source=rss-51094fd1f377------2</link>
            <guid isPermaLink="false">https://medium.com/p/debf2d9bf713</guid>
            <dc:creator><![CDATA[Amit Nishad]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 09:31:26 GMT</pubDate>
            <atom:updated>2025-03-21T09:31:26.836Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Have you ever wondered how databases maintain accuracy, reliability, and consistency even when multiple users perform transactions simultaneously? This is possible because of <strong>ACID properties</strong> — the foundation of any reliable database system</p><p><strong>we will explore:</strong><br><em> What ACID properties are<br> Why they are important<br> Real-world examples for better understanding</em></p><p>Let’s dive in!</p><ol><li>What Are ACID Properties?</li></ol><p><strong>ACID</strong> stands for <strong>Atomicity, Consistency, Isolation, and Durability</strong> — four essential principles that ensure data remains accurate and reliable in a database, even in cases of system failures or concurrent transactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P3j4hmkQzzNhe_johxVzJA.jpeg" /></figure><ul><li>🟡 <strong>A</strong> — Atomicity (All or Nothing)</li><li>🟢 <strong>C</strong> — Consistency (Data Integrity)</li><li>🔵 <strong>I</strong> — Isolation (No Interference)</li><li>🔴 <strong>D</strong> — Durability (Permanent Storage</li></ul><p><strong>2. Understanding Each ACID Property (With Examples)</strong></p><h3>🟡 Atomicity — All or Nothing</h3><p>Atomicity ensures that a transaction is <strong>completely executed or not executed at all</strong>. If any part of the transaction fails, the entire operation is rolled back, ensuring no partial changes occur.</p><p>💡 <strong>Example:</strong><br> Imagine you are transferring ₹1000 from <strong>Account A</strong> to <strong>Account B</strong>. This transaction consists of two steps:</p><ol><li><strong>Debit ₹1000 from Account A</strong></li><li><strong>Credit ₹1000 to Account B</strong></li></ol><p>If the system crashes after debiting ₹1000 but before crediting it to Account B, the money would disappear! But thanks to <strong>Atomicity</strong>, the system ensures that both steps are completed, or none at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nAR33cfHpbjr7Qrj" /></figure><p>🟢 <strong>Start</strong> → 💰 <strong>Debit Sender</strong> → 💰 <strong>Credit Receiver</strong> → ✅ <strong>Success</strong><br> 🔴 If any step fails → <strong>Rollback</strong> (Reverse transaction)</p><h3><strong>🟢 Consistency — Maintain Data Integrity</strong></h3><p>Consistency ensures that a database moves from <strong>one valid state to another valid state</strong>, maintaining data integrity.</p><p>💡 <strong>Example:</strong><br> Let’s say a bank follows this rule:</p><blockquote><em>“Total balance across all accounts must always remain ₹10,00,000.”</em></blockquote><p>If someone transfers money from one account to another, the total sum should <strong>not</strong> change. If a failure occurs, <strong>Consistency ensures that no invalid data is stored</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*TFDjr_z9zEHRks7U00oZqw.png" /></figure><h3>🔵 Isolation — No Interference Between Transactions</h3><p>Isolation ensures that multiple transactions can execute <strong>simultaneously without affecting each other</strong>.</p><p>💡 <strong>Example:</strong><br> Imagine two people trying to <strong>book the last ticket</strong> for a concert at the same time:</p><ol><li><strong>User A selects the ticket (1 seat left).</strong></li><li><strong>User B selects the ticket at the same time.</strong></li><li><strong>Both try to book it simultaneously.</strong></li></ol><p>Without <strong>Isolation</strong>, both could succeed, causing <strong>overbooking</strong>! Databases prevent this by using different <strong>isolation levels</strong> to control how transactions interact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*DATXWDN-j_yCc1FK1BZ5vA.png" /></figure><h3>🔴 Durability — Permanent Changes</h3><p>Durability ensures that <strong>once a transaction is committed, it remains permanently stored</strong>, even if the system crashes.</p><p>💡 <strong>Example:</strong><br> After transferring money from <strong>Account A to Account B</strong>, the transaction should remain safe even if the power goes out. <strong>Durability ensures this by storing committed transactions in non-volatile memory.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*71EcL-2_YVulvYav" /></figure><h3>3. How ACID Properties Are Implemented in Databases</h3><p>Modern databases ensure ACID compliance using:<br> ✔ <strong>Transaction Logs:</strong> To track changes and rollback failures<br> ✔ <strong>Concurrency Control:</strong> To handle multiple transactions safely<br> ✔ <strong>Write-Ahead Logging (WAL):</strong> To store transactions before executing</p><p>Most popular databases — <strong>MySQL, PostgreSQL, Oracle, SQL Server</strong> — use these mechanisms to ensure data reliability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*63fyqz3hqpPcwA1ewdGCsw.png" /></figure><h3>4. Why ACID Properties Are Crucial for Databases</h3><p>Without ACID properties, databases would face problems like:<br> 🚨 <strong>Lost Transactions</strong> — Data could disappear if a crash occurs.<br> ⚠ <strong>Dirty Reads</strong> — Transactions could read incomplete or incorrect data.<br> ⛔ <strong>Data Corruption</strong> — Invalid or inconsistent data could be stored.</p><p>By ensuring <strong>Atomicity, Consistency, Isolation, and Durability</strong>, databases guarantee <strong>data integrity, security, and reliability</strong> — which is critical for applications like <strong>banking, e-commerce, healthcare, and finance</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*UO67eITf_lmXSf1ywIbnYg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=debf2d9bf713" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>