<?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: Ilakkiya</title>
    <description>The latest articles on DEV Community by Ilakkiya (@ilakkiya_99033c7a7246d48b).</description>
    <link>https://dev.to/ilakkiya_99033c7a7246d48b</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%2F3448239%2Fd243d40f-ef4a-4752-b476-9eec028784cb.png</url>
      <title>DEV Community: Ilakkiya</title>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilakkiya_99033c7a7246d48b"/>
    <language>en</language>
    <item>
      <title>MongoDB CRUD Operations</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Sun, 05 Oct 2025 04:12:41 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/mongodb-crud-operations-a-hands-on-guide-with-student-data-3hkd</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/mongodb-crud-operations-a-hands-on-guide-with-student-data-3hkd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Databases don’t always have to be tables and rows — welcome to the world of MongoDB, where data lives as flexible documents!&lt;br&gt;
In this post, we’ll explore how to perform the four basic operations — Create, Read, Update, and Delete (CRUD) — using a simple college student schema in MongoDB.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We’ll be using MongoDB Atlas, a free cloud-based platform that allows you to create and manage MongoDB databases online — no installation needed!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Steps to Set Up.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Head over to MongoDB Atlas and sign up for a free account.&lt;/li&gt;
&lt;li&gt;Create a new Cluster (choose the free M0 shared tier).&lt;/li&gt;
&lt;li&gt;Once your cluster is ready, go to Collections → Create Database.&lt;/li&gt;
&lt;li&gt;Name your database collegeDB and add a collection named students.&lt;/li&gt;
&lt;li&gt;Open the Atlas Data Explorer — this is where you’ll run all your MongoDB commands.&lt;/li&gt;
&lt;/ol&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%2Fqnjfzo59nrk18ac6rs6h.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%2Fqnjfzo59nrk18ac6rs6h.png" alt=" " width="800" height="377"&gt;&lt;/a&gt;&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%2Fmophtk59vpvhqydeipsm.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%2Fmophtk59vpvhqydeipsm.png" alt=" " width="800" height="371"&gt;&lt;/a&gt;&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%2Fb5ln96nh3eavjz5neisp.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%2Fb5ln96nh3eavjz5neisp.png" alt=" " width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Schema: Student Collection
&lt;/h2&gt;

&lt;p&gt;We’ll use a collection called students, where each document looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "student_id": "S001",
  "name": "Santhosh",
  "age": 20,
  "department": "CSBS",
  "year": 2,
  "cgpa": 9
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F02ibuf86t21ney9azr1c.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%2F02ibuf86t21ney9azr1c.png" alt=" " width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create (Insert Documents)
&lt;/h2&gt;

&lt;p&gt;We’ll begin by inserting five sample student records.&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%2F0shxrq6wxqorelcqt84n.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%2F0shxrq6wxqorelcqt84n.png" alt=" " width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Read (Query Documents)
&lt;/h2&gt;

&lt;p&gt;Once data is inserted, let’s retrieve it using different query conditions.&lt;br&gt;
&lt;strong&gt;Display All Student Records&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.find();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ff40j64f9zw3qars3w8x8.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%2Ff40j64f9zw3qars3w8x8.png" alt=" " width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Find Students with CGPA &amp;gt; 8&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.find({ cgpa: { $gt: 8 } });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fq72hv15xrr4tkcbwu2wu.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%2Fq72hv15xrr4tkcbwu2wu.png" alt=" " width="800" height="376"&gt;&lt;/a&gt;&lt;br&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%2Foseic5t0gym684k8gnws.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%2Foseic5t0gym684k8gnws.png" alt=" " width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Find Students from the Computer Science Department&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.find({ department: "CSBS" });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ff96t05s8xzsoxem44prc.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%2Ff96t05s8xzsoxem44prc.png" alt=" " width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Update (Modify Documents)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Update a Specific Student’s CGPA&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.updateOne(
  { student_id: "S001" },
  { $set: { cgpa: 8 } }
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fpbskfynsdalomk1n9zcz.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%2Fpbskfynsdalomk1n9zcz.png" alt=" " width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Increase the Year of Study for All 3rd-Year Students&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.updateMany(
  { year: 3 },
  { $inc: { year: 1 } }
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fkrf6pujqbh2ceubxkqqw.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%2Fkrf6pujqbh2ceubxkqqw.png" alt=" " width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Delete (Remove Documents)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Delete One Student by ID&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.deleteOne({ student_id: "S005" });

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

&lt;/div&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%2Fuf33a9ov21ff66ynky6n.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%2Fuf33a9ov21ff66ynky6n.png" alt=" " width="800" height="375"&gt;&lt;/a&gt;&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%2Fuxgpd9qsir5mtgt8j6r0.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%2Fuxgpd9qsir5mtgt8j6r0.png" alt=" " width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Delete All Students with CGPA &amp;lt; 7.5&lt;/strong&gt;&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%2Fie7n9ijvvc7hwenjthsl.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%2Fie7n9ijvvc7hwenjthsl.png" alt=" " width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;✔ Create → Add new student documents&lt;br&gt;
✔ Read → Query and filter documents efficiently&lt;br&gt;
✔ Update → Modify existing records dynamically&lt;br&gt;
✔ Delete → Safely remove unwanted data&lt;/p&gt;

&lt;p&gt;MongoDB makes database handling simple, fast, and flexible — perfect for modern applications that evolve with changing data needs.&lt;/p&gt;

&lt;h1&gt;
  
  
  mongodb #nosql #crud #database #learning #devcommunity #webdev
&lt;/h1&gt;

</description>
      <category>database</category>
      <category>tutorial</category>
      <category>mongodb</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Indexing, Hashing &amp; Query Optimization in SQL</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Sun, 05 Oct 2025 02:29:14 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/indexing-hashing-query-optimization-in-sql-5ell</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/indexing-hashing-query-optimization-in-sql-5ell</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Have you ever noticed how some database queries return results almost instantly — even when the table has thousands of rows?&lt;br&gt;
That’s the magic of Indexing, Hashing, and Query Optimization.&lt;br&gt;
In this post, we’ll see how these techniques make databases faster and smarter — using a simple Students table as our example.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1 — Creating the Students Table
&lt;/h2&gt;

&lt;p&gt;Let’s start by creating the table and inserting 20 sample records to work with.&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%2Fuodtk9hqrlgjiazasae9.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%2Fuodtk9hqrlgjiazasae9.png" alt=" " width="800" height="133"&gt;&lt;/a&gt;&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%2Ff0bvtj25v4d55u5dd8yd.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%2Ff0bvtj25v4d55u5dd8yd.png" alt=" " width="531" height="418"&gt;&lt;/a&gt;&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%2F6gq6os5ekztmqbwpuzj2.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%2F6gq6os5ekztmqbwpuzj2.png" alt=" " width="772" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 — B-Tree Index on roll_no
&lt;/h2&gt;

&lt;p&gt;B-Tree indexing is the default and most common type of index in relational databases.&lt;br&gt;
It helps in quickly locating rows based on range queries or sorted data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE INDEX idx_rollno_btree
ON Students(roll_no);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s use that index to fetch a student’s details efficiently.&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%2Fus3korp63w1j86nv4rxe.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%2Fus3korp63w1j86nv4rxe.png" alt=" " width="526" height="124"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Result:&lt;/strong&gt; The database uses the B-Tree index to find the record in milliseconds.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3 — B+ Tree Index on cgpa
&lt;/h2&gt;

&lt;p&gt;A B+ Tree index is an enhancement of the B-Tree — perfect for range-based queries, such as finding all students with CGPA above a threshold.&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%2Fsrupr40sid0v4pb349f0.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%2Fsrupr40sid0v4pb349f0.png" alt=" " width="554" height="70"&gt;&lt;/a&gt;&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%2F9ihlkixjicxecxq8mf9m.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%2F9ihlkixjicxecxq8mf9m.png" alt=" " width="621" height="359"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Result:&lt;/strong&gt; The database quickly retrieves qualifying students without scanning the entire table.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4 — Hash Index on dept
&lt;/h2&gt;

&lt;p&gt;Hash indexing is great for exact matches, such as looking up a department by name.&lt;br&gt;
It uses hash functions to map keys directly to data locations — extremely fast for equality checks.&lt;/p&gt;
&lt;h3&gt;
  
  
  HASH index using an in-memory table:
&lt;/h3&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%2Fylzgvvdhdl2vlmame9fi.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%2Fylzgvvdhdl2vlmame9fi.png" alt=" " width="582" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A MEMORY table is stored in RAM. If the database server restarts, the MEMORY table disappears. Use it only for temporary, very fast lookups.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; The database directly jumps to all CSBS records using the hash key — no full scan required.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 5 — Query Optimization in Action
&lt;/h2&gt;

&lt;p&gt;Indexes and hashing dramatically improve performance by reducing search time and optimizing query execution plans.&lt;br&gt;
To see the difference, you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EXPLAIN SELECT * FROM Students WHERE cgpa &amp;gt; 8.0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F9m15razapibva52iu1cz.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%2F9m15razapibva52iu1cz.png" alt=" " width="800" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Result:&lt;/strong&gt; The plan shows the use of indexes, confirming optimized access paths.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; B-Tree Index – Ideal for range and sorted queries&lt;/li&gt;
&lt;li&gt; B+ Tree Index – Efficient for range lookups with dense leaf nodes&lt;/li&gt;
&lt;li&gt; Hash Index – Perfect for equality comparisons&lt;/li&gt;
&lt;li&gt; Query Optimization – The key to high-speed, low-latency data retrieval&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Indexes are like shortcuts for the database — they make searching faster, queries smarter, and performance smoother.&lt;/p&gt;

&lt;h1&gt;
  
  
  SQL #Indexing #Hashing #QueryOptimization #Database #Learning #DevCommunity
&lt;/h1&gt;

</description>
      <category>database</category>
      <category>tutorial</category>
      <category>performance</category>
      <category>sql</category>
    </item>
    <item>
      <title>Transactions, Deadlocks &amp; Log-Based Recovery in SQL</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Sat, 04 Oct 2025 18:31:39 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/transactions-deadlocks-log-based-recovery-in-sql-42nm</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/transactions-deadlocks-log-based-recovery-in-sql-42nm</guid>
      <description>&lt;p&gt;Database systems are designed to handle multiple operations efficiently and reliably.&lt;br&gt;
In this post, we’ll explore three key concepts that keep databases safe and consistent: Transactions, Deadlocks, and Log-Based Recovery.&lt;br&gt;
We’ll use a simple Accounts table to demonstrate these concepts in action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the Accounts Table
&lt;/h2&gt;

&lt;p&gt;We start with a simple table to represent bank accounts and insert sample data.&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%2Flopef19h9sacqinmhziz.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%2Flopef19h9sacqinmhziz.png" alt=" " width="420" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Transactions — Atomicity &amp;amp; Rollback
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
A transaction is a sequence of operations that must be executed completely or not at all.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Transfer Money with Rollback&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt; Transfer 700 from Diana to Ethan, but rollback before committing.&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%2F950lo8org52e4z5m9uin.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%2F950lo8org52e4z5m9uin.png" alt=" " width="525" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Result:&lt;/strong&gt; No partial update occurs; balances remain unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deadlock Simulation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
A deadlock occurs when two transactions block each other, waiting for resources the other holds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Scenario&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Session 1: Lock Diana's account &amp;amp; try to update Ethan's account&lt;/em&gt;&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%2Fcvag9k2gdptrfz3kc6tk.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%2Fcvag9k2gdptrfz3kc6tk.png" alt=" " width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Session 2:Lock Ethan's account &amp;amp; Try to update Diana's account&lt;/em&gt;&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%2F9iwd5v4k6aj2vcigiryz.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%2F9iwd5v4k6aj2vcigiryz.png" alt=" " width="800" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both sessions wait indefinitely, creating a deadlock that the DBMS detects and resolves.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Log-Based Recovery
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
Logging ensures that every database change is recorded, so the system can undo or redo transactions during failures.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Transaction with Undo Logging&lt;/em&gt;&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%2Fmhi9pporqee2m7768lq1.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%2Fmhi9pporqee2m7768lq1.png" alt=" " width="800" height="306"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Result:&lt;/em&gt;&lt;/strong&gt; The rollback operation is recorded in the log, ensuring data consistency.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Transactions: Ensure atomicity — all or nothing.&lt;/li&gt;
&lt;li&gt; Deadlocks: Occur when transactions wait on each other; DBMS resolves them automatically.&lt;/li&gt;
&lt;li&gt; Log-Based Recovery: Maintains a history of changes to recover from failures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These mechanisms are fundamental to robust, reliable, and fault-tolerant database systems.&lt;/p&gt;

&lt;h1&gt;
  
  
  SQL #Database #Transactions #Deadlocks #Recovery #Learning #DevCommunity
&lt;/h1&gt;

</description>
      <category>database</category>
      <category>tutorial</category>
      <category>computerscience</category>
      <category>sql</category>
    </item>
    <item>
      <title>ACID Properties in SQL Transactions</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Sat, 04 Oct 2025 17:57:59 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/acid-properties-in-sql-transactions-3f80</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/acid-properties-in-sql-transactions-3f80</guid>
      <description>&lt;p&gt;Managing data might seem straightforward, but behind every secure and reliable database are rules that ensure nothing breaks.&lt;br&gt;
Let’s dive into ACID properties and see how SQL transactions guarantee that our operations are safe, consistent, and permanent — demonstrated with a simple Accounts table.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating the Accounts Table
&lt;/h2&gt;

&lt;p&gt;We start by creating a table to hold account information and inserting some sample data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Accounts (
  acc_no INT PRIMARY KEY,
  name VARCHAR(50),
  balance INT CHECK (balance &amp;gt;= 0)
) ENGINE=InnoDB;

INSERT INTO Accounts VALUES
(201, 'Arjun', 12000),
(202, 'Diya', 9500),
(203, 'Vikram', 7000);

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

&lt;/div&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%2Fztdzbpa1ichzjxf23x7d.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%2Fztdzbpa1ichzjxf23x7d.png" alt=" " width="549" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Atomicity — All or Nothing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
A transaction must be atomic: either all operations succeed, or none do.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Money Transfer with Rollback&lt;/em&gt;&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%2Fdj66m9ws0mlgu851sm9l.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%2Fdj66m9ws0mlgu851sm9l.png" alt=" " width="683" height="381"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Consistency — Maintain Data Rules
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
Transactions must leave the database in a valid state, respecting all constraints.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Prevent Negative Balance&lt;/em&gt;&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%2Fdbcov4uzjhefhyqwkgku.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%2Fdbcov4uzjhefhyqwkgku.png" alt=" " width="642" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; The database rejected the invalid insert, maintaining consistent data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Isolation — Transactions Don’t Interfere
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
Concurrent transactions should not affect each other’s operations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Simulate Two Sessions&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session 1 (User A)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;START TRANSACTION;
UPDATE Accounts SET balance = balance - 2000 WHERE acc_no = 201;
SELECT * FROM Accounts WHERE acc_no = 201;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fu9neogdaxsj2jf5wj7m7.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%2Fu9neogdaxsj2jf5wj7m7.png" alt=" " width="689" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session 2 (User B)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM Accounts WHERE acc_no = 201;

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

&lt;/div&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%2Fkm2y8581hdq6yr5mjwmp.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%2Fkm2y8581hdq6yr5mjwmp.png" alt=" " width="525" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Session 2 doesn’t see the uncommitted changes from Session1.&lt;br&gt;
Now User A commits and checks again:&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%2Fkdjcxwun6vebem49083m.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%2Fkdjcxwun6vebem49083m.png" alt=" " width="618" height="295"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Change visible only after commit → Isolation works.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Durability — Permanent Once Committed
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br&gt;
Once a transaction is committed, its changes persist even if the database restarts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Commit and Verify&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;START TRANSACTION;
UPDATE Accounts SET balance = balance + 1500 WHERE acc_no = 203;  -- Vikram gains ₹1500
COMMIT;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fmoiasg33vcu74w706x17.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%2Fmoiasg33vcu74w706x17.png" alt=" " width="639" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Restart the database and run:&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%2Fs9u3hk9bhqxe41kfq3q2.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%2Fs9u3hk9bhqxe41kfq3q2.png" alt=" " width="549" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Summary&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;✅ Atomicity: No partial updates&lt;br&gt;
✅ Consistency: Only valid data allowed&lt;br&gt;
✅ Isolation: Transactions don’t interfere&lt;br&gt;
✅ Durability: Changes survive system failures&lt;/p&gt;

&lt;p&gt;ACID properties ensure databases are reliable, robust, and safe, making SQL transactions predictable and trustworthy.&lt;/p&gt;

&lt;h1&gt;
  
  
  SQL #Transactions #ACID #DatabaseDesign #Learning #DevCommunity
&lt;/h1&gt;

</description>
      <category>database</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>sql</category>
    </item>
    <item>
      <title>SQL Cursors and Triggers</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Sat, 04 Oct 2025 17:18:27 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/sql-cursors-and-triggers-30f0</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/sql-cursors-and-triggers-30f0</guid>
      <description>&lt;p&gt;This post explores Cursor and Trigger in SQL with practical examples in a way that’s easy to understand.&lt;br&gt;
This post explores Cursor and Trigger in SQL with practical examples in a way that’s easy to understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cursor — Processing Rows with a Condition&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A cursor allows you to process query results row by row, especially when you need to apply logic or conditions that can’t be handled by a single SQL statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Objective&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Display employee names whose salary is greater than 50,000 using a cursor.&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%2Fwetgwcqlnx8adl42rmqh.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%2Fwetgwcqlnx8adl42rmqh.png" alt=" " width="631" height="298"&gt;&lt;/a&gt;&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%2F0yqan9trjlfnekyyoc12.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%2F0yqan9trjlfnekyyoc12.png" alt=" " width="346" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Trigger — Automating an Action After INSERT&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A trigger automatically executes a set of SQL statements when a specific database event (like INSERT, UPDATE, or DELETE) occurs.&lt;br&gt;
Here, we’ll use an AFTER INSERT trigger to maintain a student registration log.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Objective&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever a new record is added to the Students table, automatically insert an entry into the Student_Audit table.&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%2Fzfoi89vysuvo58w3vqwq.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%2Fzfoi89vysuvo58w3vqwq.png" alt=" " width="558" height="255"&gt;&lt;/a&gt;&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%2F89bh6st3c216tg37ljkn.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%2F89bh6st3c216tg37ljkn.png" alt=" " width="583" height="160"&gt;&lt;/a&gt;&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%2Fhbsv3b3odek1kqcyg0vg.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%2Fhbsv3b3odek1kqcyg0vg.png" alt=" " width="607" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**Testing the Trigger&lt;/p&gt;

&lt;p&gt;**&lt;br&gt;
When a new student record is inserted, the trigger automatically creates a log entry in the Student_Audit table.&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%2Fq8yl4nmf0em2uis6lbsi.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%2Fq8yl4nmf0em2uis6lbsi.png" alt=" " width="675" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;✔ Cursor – Processes data row by row for conditional operations.&lt;br&gt;
✔ Trigger – Automates database actions after an event.&lt;/p&gt;

&lt;p&gt;Both help make SQL more dynamic, controlled, and responsive to real-time data changes.&lt;/p&gt;

&lt;h1&gt;
  
  
  sql #database #cursor #trigger #learning #devbeginners
&lt;/h1&gt;

</description>
      <category>database</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>sql</category>
    </item>
    <item>
      <title>Understanding 1NF, 2NF, and 3NF Using SQL — Step-by-Step Implementation</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Sat, 04 Oct 2025 16:31:55 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/understanding-1nf-2nf-and-3nf-using-sql-step-by-step-implementation-4bm2</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/understanding-1nf-2nf-and-3nf-using-sql-step-by-step-implementation-4bm2</guid>
      <description>&lt;p&gt;Database normalization is a process used to organize data in a database efficiently.It helps to remove redundancy, improve data integrity, and make data maintenance easier.&lt;br&gt;
This post walks through the process of converting a database into 1NF, 2NF, and 3NF, showing each stage with practical SQL CREATE TABLE and INSERT examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Base Table&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s start with the following unnormalized Student Enrollment table:&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%2Fxhlzstzo435z0qr5xx03.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%2Fxhlzstzo435z0qr5xx03.png" alt=" " width="624" height="168"&gt;&lt;/a&gt;&lt;br&gt;
This table stores student details, courses, and instructor information together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Data Anomalies&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This unnormalized table can cause three types of anomalies:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Insertion anomaly:&lt;/strong&gt;&lt;br&gt;
Cannot add a new course unless a student is enrolled in it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update anomaly:&lt;/strong&gt;&lt;br&gt;
If an instructor’s phone number changes, it must be updated in multiple rows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deletion anomaly:&lt;/strong&gt;&lt;br&gt;
Deleting a student record might also remove information about a course or instructor.&lt;/p&gt;

&lt;p&gt;To overcome these issues, we will normalize the table step by step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: First Normal Form (1NF)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each column should contain atomic (single) values.&lt;/li&gt;
&lt;li&gt;No repeating groups or arrays are allowed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE Student_1NF (&lt;br&gt;
    StudentID INT,&lt;br&gt;
    StudentName VARCHAR(50),&lt;br&gt;
    Course VARCHAR(50),&lt;br&gt;
    Instructor VARCHAR(50),&lt;br&gt;
    InstructorPhone VARCHAR(15)&lt;br&gt;
);&lt;/code&gt;&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%2F3f323r9wizsrf5dtkgvh.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%2F3f323r9wizsrf5dtkgvh.png" alt=" " width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Second Normal Form (2NF)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The table must be in 1NF.&lt;/li&gt;
&lt;li&gt;All non-key attributes must depend on the entire primary key, not just a part of it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE Students (&lt;br&gt;
    StudentID VARCHAR(10) PRIMARY KEY,&lt;br&gt;
    StudentName VARCHAR(100) NOT NULL&lt;br&gt;
);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE Courses_2NF (&lt;br&gt;
    CourseID VARCHAR(10) PRIMARY KEY,&lt;br&gt;
    CourseName VARCHAR(100) NOT NULL,&lt;br&gt;
    Instructor VARCHAR(100) NOT NULL,&lt;br&gt;
    InstructorPhone VARCHAR(15) NOT NULL&lt;br&gt;
);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE Enrollments_2NF (&lt;br&gt;
    StudentID VARCHAR(10) NOT NULL,&lt;br&gt;
    CourseID VARCHAR(10) NOT NULL,&lt;br&gt;
    PRIMARY KEY (StudentID, CourseID),&lt;br&gt;
    FOREIGN KEY (StudentID) REFERENCES Students(StudentID),&lt;br&gt;
    FOREIGN KEY (CourseID) REFERENCES Courses_2NF(CourseID)&lt;br&gt;
);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO Students (StudentID, StudentName) VALUES&lt;br&gt;
('S01','Arjun'),&lt;br&gt;
('S02','Priya'),&lt;br&gt;
('S03','Kiran');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO Courses_2NF (CourseID, CourseName, Instructor, InstructorPhone) VALUES&lt;br&gt;
('C101','DBMS','Dr. Kumar','9876543210'),&lt;br&gt;
('C102','Data Mining','Dr. Mehta','9123456780'),&lt;br&gt;
('C103','AI','Dr. Rao','9988776655');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO Enrollments_2NF (StudentID, CourseID) VALUES&lt;br&gt;
('S01','C101'),('S01','C102'),('S02','C101'),('S03','C103');&lt;/code&gt;&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%2F7weedd86sk5tt4l9xfam.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%2F7weedd86sk5tt4l9xfam.png" alt=" " width="694" height="373"&gt;&lt;/a&gt;&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%2F69qsm599nqx8twb4vhia.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%2F69qsm599nqx8twb4vhia.png" alt=" " width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Third Normal Form (3NF)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The table must be in 2NF.&lt;/li&gt;
&lt;li&gt;There should be no transitive dependency (non-key attributes should not depend on other non-key attributes).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, InstructorPhone depends on Instructor, not on the key — so we separate instructor details into a new table.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE StudentDetails (&lt;br&gt;
    StudentID VARCHAR(10) PRIMARY KEY,&lt;br&gt;
    StudentName VARCHAR(100) NOT NULL&lt;br&gt;
) ENGINE=InnoDB;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE InstructorDetails (&lt;br&gt;
    InstructorID VARCHAR(10) PRIMARY KEY,&lt;br&gt;
    InstructorName VARCHAR(100) NOT NULL,&lt;br&gt;
    InstructorPhone VARCHAR(15) NOT NULL&lt;br&gt;
) ENGINE=InnoDB;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE CourseDetails (&lt;br&gt;
    CourseID VARCHAR(10) PRIMARY KEY,&lt;br&gt;
    CourseName VARCHAR(100) NOT NULL,&lt;br&gt;
    InstructorID VARCHAR(10) NOT NULL,&lt;br&gt;
    FOREIGN KEY (InstructorID) REFERENCES InstructorDetails(InstructorID)&lt;br&gt;
) ENGINE=InnoDB;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE StudentCourseEnrollments (&lt;br&gt;
    StudentID VARCHAR(10) NOT NULL,&lt;br&gt;
    CourseID VARCHAR(10) NOT NULL,&lt;br&gt;
    PRIMARY KEY (StudentID, CourseID),&lt;br&gt;
    FOREIGN KEY (StudentID) REFERENCES StudentDetails(StudentID),&lt;br&gt;
    FOREIGN KEY (CourseID) REFERENCES CourseDetails(CourseID)&lt;br&gt;
) ENGINE=InnoDB;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO StudentDetails (StudentID, StudentName) VALUES&lt;br&gt;
('S11','Rohan'),&lt;br&gt;
('S12','Meera'),&lt;br&gt;
('S13','Vikram'),&lt;br&gt;
('S14','Sneha');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO InstructorDetails (InstructorID, InstructorName, InstructorPhone) VALUES&lt;br&gt;
('I11','Dr. Sharma','9871112233'),&lt;br&gt;
('I12','Dr. Nair','9122223344'),&lt;br&gt;
('I13','Dr. Kapoor','9988771122'),&lt;br&gt;
('I14','Dr. Joshi','9899988776');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO CourseDetails (CourseID, CourseName, InstructorID) VALUES&lt;br&gt;
('C201','Operating Systems','I11'),&lt;br&gt;
('C202','Computer Networks','I12'),&lt;br&gt;
('C203','Machine Learning','I13'),&lt;br&gt;
('C204','Cloud Computing','I14');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO StudentCourseEnrollments (StudentID, CourseID) VALUES&lt;br&gt;
('S11','C201'),&lt;br&gt;
('S11','C202'),&lt;br&gt;
('S12','C201'),&lt;br&gt;
('S13','C203'),&lt;br&gt;
('S14','C204');&lt;/code&gt;&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%2F0llvx37bdzw5z0f5hk9m.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%2F0llvx37bdzw5z0f5hk9m.png" alt=" " width="760" height="487"&gt;&lt;/a&gt;&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%2F2gphaiezsdmyb1n9wn68.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%2F2gphaiezsdmyb1n9wn68.png" alt=" " width="771" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this stage, the database is fully normalized into Third Normal Form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Displaying All Students with Their Courses and Instructors&lt;/strong&gt;&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%2Fdyn3leew5iyeyjbuujl4.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%2Fdyn3leew5iyeyjbuujl4.png" alt=" " width="800" height="204"&gt;&lt;/a&gt;&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%2F4ujjxx8k2aw5iecz9sx2.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%2F4ujjxx8k2aw5iecz9sx2.png" alt=" " width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Through these steps, we successfully:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identified anomalies in the base table&lt;/li&gt;
&lt;li&gt;Converted it to 1NF, 2NF, and 3NF&lt;/li&gt;
&lt;li&gt;Used SQL commands to design normalized tables&lt;/li&gt;
&lt;li&gt;Joined the data to display meaningful results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Database normalization not only removes redundancy but also ensures that data remains consistent and easy to maintain.&lt;/p&gt;

&lt;h1&gt;
  
  
  sql #database #normalization #learning #assignments
&lt;/h1&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>College Database Management System – Oracle LiveSQL</title>
      <dc:creator>Ilakkiya</dc:creator>
      <pubDate>Wed, 20 Aug 2025 16:28:20 +0000</pubDate>
      <link>https://dev.to/ilakkiya_99033c7a7246d48b/college-database-management-system-oracle-livesql-1i1i</link>
      <guid>https://dev.to/ilakkiya_99033c7a7246d48b/college-database-management-system-oracle-livesql-1i1i</guid>
      <description>&lt;p&gt;This project demonstrates how to design and query a mini College Database Management System (DBMS) using Oracle LiveSQL. The aim is to understand how real-world college data like students, faculty, courses, and enrollments can be efficiently stored, managed, and retrieved using SQL.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Schema Design&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We create four core tables with proper constraints to maintain data integrity:&lt;/p&gt;

&lt;p&gt;Faculty – stores teacher details such as FacultyID, FacultyName, Department, and Email.&lt;/p&gt;

&lt;p&gt;Students – contains student details including StudentID, Name, Department, Date of Birth, Email, and Phone number.&lt;/p&gt;

&lt;p&gt;Courses – holds subject details like CourseID, CourseName, and Credits (restricted between 1–5).&lt;/p&gt;

&lt;p&gt;Enrollments – acts as a bridge (many-to-many relationship) between Students and Courses, mapping students to their registered courses along with their grades.&lt;/p&gt;

&lt;p&gt;This schema ensures relational integrity by applying primary keys, unique keys, foreign keys, and constraints.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Sample Queries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the schema is created, we run different types of queries to explore SQL operations:&lt;/p&gt;

&lt;p&gt;String Functions &amp;amp; Aggregates&lt;/p&gt;

&lt;p&gt;SELECT UPPER(Name), LENGTH(Email) FROM Students;&lt;br&gt;
SELECT AVG(Credits) AS AvgCredits, COUNT(*) AS TotalStudents &lt;br&gt;
FROM Courses, Students;&lt;/p&gt;

&lt;p&gt;These queries display student names in uppercase, measure email lengths, and calculate the average course credits.&lt;/p&gt;

&lt;p&gt;Joins&lt;br&gt;
To display the mapping between students, courses, and their grades:&lt;/p&gt;

&lt;p&gt;SELECT s.Name, c.CourseName, e.Grade&lt;br&gt;&lt;br&gt;
FROM Students s&lt;br&gt;&lt;br&gt;
JOIN Enrollments e ON s.StudentID = e.StudentID&lt;br&gt;&lt;br&gt;
JOIN Courses c ON e.CourseID = c.CourseID;&lt;/p&gt;

&lt;p&gt;Group By + Having&lt;br&gt;
To analyze the student distribution across departments:&lt;/p&gt;

&lt;p&gt;SELECT Dept, COUNT(&lt;em&gt;) AS StudentCount&lt;br&gt;&lt;br&gt;
FROM Students&lt;br&gt;&lt;br&gt;
GROUP BY Dept&lt;br&gt;&lt;br&gt;
HAVING COUNT(&lt;/em&gt;) &amp;gt; 2;&lt;/p&gt;

&lt;p&gt;This ensures only departments with more than two students are displayed.&lt;/p&gt;

&lt;p&gt;🔹** Views &amp;amp; Procedures**&lt;/p&gt;

&lt;p&gt;Views&lt;br&gt;
A view named StudentCoursesView is created to simplify repeated queries:&lt;/p&gt;

&lt;p&gt;CREATE VIEW StudentCoursesView AS&lt;br&gt;&lt;br&gt;
SELECT s.Name AS StudentName, c.CourseName, e.Grade&lt;br&gt;&lt;br&gt;
FROM Students s&lt;br&gt;&lt;br&gt;
JOIN Enrollments e ON s.StudentID = e.StudentID&lt;br&gt;&lt;br&gt;
JOIN Courses c ON e.CourseID = c.CourseID;&lt;/p&gt;

&lt;p&gt;This allows users to easily fetch student-course-grade data without rewriting complex joins.&lt;/p&gt;

&lt;p&gt;Stored Procedures&lt;br&gt;
To update student grades efficiently, we write a procedure:&lt;/p&gt;

&lt;p&gt;CREATE OR REPLACE PROCEDURE UpdateGrade(&lt;br&gt;
    p_StudentID IN NUMBER,&lt;br&gt;
    p_CourseID IN NUMBER,&lt;br&gt;
    p_NewGrade IN CHAR&lt;br&gt;
) AS&lt;br&gt;&lt;br&gt;
BEGIN&lt;br&gt;&lt;br&gt;
    UPDATE Enrollments&lt;br&gt;&lt;br&gt;
    SET Grade = p_NewGrade&lt;br&gt;&lt;br&gt;
    WHERE StudentID = p_StudentID AND CourseID = p_CourseID;&lt;br&gt;&lt;br&gt;
END;  &lt;/p&gt;

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

&lt;p&gt;This project demonstrates a complete database workflow:&lt;/p&gt;

&lt;p&gt;Designing relational schemas with constraints&lt;/p&gt;

&lt;p&gt;Inserting and modifying data&lt;/p&gt;

&lt;p&gt;Executing SQL queries with functions, joins, and grouping&lt;/p&gt;

&lt;p&gt;Creating views for simplicity&lt;/p&gt;

&lt;p&gt;Automating updates with stored procedures&lt;/p&gt;

&lt;p&gt;By working on this mini-project in Oracle LiveSQL, we gain practical insights into how a College DBMS operates. It not only strengthens SQL knowledge but also builds a strong foundation for handling larger real-world databases.&lt;br&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%2F8d75h9a7e8bg9zfseosp.jpeg" 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%2F8d75h9a7e8bg9zfseosp.jpeg" alt=" " width="800" height="379"&gt;&lt;/a&gt;&lt;br&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%2F9ws6q32ykjy1vy6z4z1a.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%2F9ws6q32ykjy1vy6z4z1a.png" alt=" " width="800" height="346"&gt;&lt;/a&gt;&lt;br&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%2F6hs190lc3cc6te8z8yj6.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%2F6hs190lc3cc6te8z8yj6.png" alt=" " width="800" height="346"&gt;&lt;/a&gt;&lt;br&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%2Fa83igzodsgaqfdsw1y9d.jpeg" 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%2Fa83igzodsgaqfdsw1y9d.jpeg" alt=" " width="800" height="378"&gt;&lt;/a&gt;&lt;br&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%2Fw2et62sprrgqalhzkpof.jpeg" 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%2Fw2et62sprrgqalhzkpof.jpeg" alt=" " width="800" height="345"&gt;&lt;/a&gt;&lt;br&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%2F1swpjw5hn9jccqnhbmgf.jpeg" 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%2F1swpjw5hn9jccqnhbmgf.jpeg" alt=" " width="800" height="380"&gt;&lt;/a&gt;&lt;br&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%2Fiwmslcmq42f27v4u3c88.jpeg" 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%2Fiwmslcmq42f27v4u3c88.jpeg" alt=" " width="800" height="374"&gt;&lt;/a&gt; &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
