<?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: GWEDE WILLIAM RUKUDZO 24CB065</title>
    <description>The latest articles on DEV Community by GWEDE WILLIAM RUKUDZO 24CB065 (@gwede_williamrukudzo24c).</description>
    <link>https://dev.to/gwede_williamrukudzo24c</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%2F3450667%2Fe6bfb44d-2d4d-45fe-9cb6-9e3088ce1fd4.png</url>
      <title>DEV Community: GWEDE WILLIAM RUKUDZO 24CB065</title>
      <link>https://dev.to/gwede_williamrukudzo24c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gwede_williamrukudzo24c"/>
    <language>en</language>
    <item>
      <title>MongoDB - Blog - dev.to + LinkedIn Post</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Wed, 08 Oct 2025 11:29:57 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/mongodb-blog-devto-linkedin-post-2bb7</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/mongodb-blog-devto-linkedin-post-2bb7</guid>
      <description>&lt;h2&gt;
  
  
  Objective
&lt;/h2&gt;

&lt;p&gt;To gain hands-on experience in performing CRUD (Create, Read, Update, Delete) operations in MongoDB using a simple college student schema.&lt;/p&gt;

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

&lt;p&gt;Insert at least 5 student records into the students collection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Task — Create (Insert)
const { MongoClient } = require("mongodb");

//  Atlas connection string
const uri = "mongodb+srv://William:4dwQ454VgRgDtNSO@assignment.jfmqse7.mongodb.net/?retryWrites=true&amp;amp;w=majority&amp;amp;appName=Assignment";

async function run() {
    const client = new MongoClient(uri);

    try {
        await client.connect();
        console.log("Connected to MongoDB Atlas");

        const db = client.db("Assign6");
        const students = db.collection("students");

        // 5 student records
        const studentData = [
            { student_id: "S001", name: "John", age: 20, department: "CSBS", year: 2, cgpa: 9.0 },
            { student_id: "S002", name: "Emma", age: 21, department: "ECE", year: 3, cgpa: 8.7 },
            { student_id: "S003", name: "Liam", age: 19, department: "MECH", year: 1, cgpa: 8.3 },
            { student_id: "S004", name: "Olivia", age: 22, department: "CSBS", year: 4, cgpa: 9.2 },
            { student_id: "S005", name: "Noah", age: 20, department: "EEE", year: 2, cgpa: 7.8 }
        ];

        const result = await students.insertMany(studentData);
        console.log(`Successfully inserted ${result.insertedCount} student documents!`);

    } catch (err) {
        console.error("Error:", err);
    } finally {
        await client.close();
        console.log("Connection closed.");
    }
}

run();
&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%2Fmpi7eeerk0gor7qacwvf.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%2Fmpi7eeerk0gor7qacwvf.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%2Fa9ev0vg814r1li5arszw.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%2Fa9ev0vg814r1li5arszw.png" alt=" " width="800" height="191"&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%2Fooxtt0hqzpnasq6asjde.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%2Fooxtt0hqzpnasq6asjde.png" alt=" " width="800" height="193"&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%2Fgpql9t14cy33a6ay9ego.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%2Fgpql9t14cy33a6ay9ego.png" alt=" " width="800" height="196"&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%2Fn4n58jfbq7uf9d526o8y.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%2Fn4n58jfbq7uf9d526o8y.png" alt=" " width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Display all student records.&lt;/li&gt;
&lt;li&gt;Find all students with CGPA &amp;gt; 8.&lt;/li&gt;
&lt;li&gt;Find students belonging to the Computer Science department.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Task 2️ Read (Query)
const { MongoClient } = require("mongodb");

// Atlas connection string
const uri = "mongodb+srv://William:4dwQ454VgRgDtNSO@assignment.jfmqse7.mongodb.net/?retryWrites=true&amp;amp;w=majority&amp;amp;appName=Assignment\n";

async function run() {
    const client = new MongoClient(uri);

    try {
        await client.connect();
        console.log("Connected to MongoDB Atlas");

        const db = client.db("Assign6");
        const students = db.collection("students");

        // Display all student records
        const allStudents = await students.find().toArray();
        console.log("\nAll Students:");
        console.table(allStudents.map(s =&amp;gt; ({
            student_id: s.student_id,
            name: s.name,
            age: s.age,
            department: s.department,
            year: s.year,
            cgpa: s.cgpa
        })));

        // Find all students with CGPA &amp;gt; 8
        const highCgpaStudents = await students.find({ cgpa: { $gt: 8 } }).toArray();
        console.log("\nStudents with CGPA &amp;gt; 8:");
        console.table(highCgpaStudents.map(s =&amp;gt; ({
            student_id: s.student_id,
            name: s.name,
            cgpa: s.cgpa
        })));

        // Find students belonging to Computer Science department
        const csStudents = await students.find({ department: "CSE" }).toArray();
        console.log("\nComputer Science Department Students:");
        console.table(csStudents.map(s =&amp;gt; ({
            student_id: s.student_id,
            name: s.name,
            year: s.year,
            cgpa: s.cgpa
        })));

    } catch (err) {
        console.error("Error:", err);
    } finally {
        await client.close();
        console.log("Connection closed.");
    }
}

run();
&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%2Fdals5dvf95zn8erkzubg.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%2Fdals5dvf95zn8erkzubg.png" alt=" " width="800" height="367"&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%2F12o5mhibner2j7zz797u.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%2F12o5mhibner2j7zz797u.png" alt=" " width="699" height="347"&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%2Fsdpaqijdxk1y15q36yi2.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%2Fsdpaqijdxk1y15q36yi2.png" alt=" " width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Update
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Update the CGPA of a specific student.&lt;/li&gt;
&lt;li&gt;Increase the year of study for all 3rd year students by 1.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Task 3️ — Update
const { MongoClient } = require("mongodb");

// connection string
const uri = "mongodb+srv://William:4dwQ454VgRgDtNSO@assignment.jfmqse7.mongodb.net/?retryWrites=true&amp;amp;w=majority&amp;amp;appName=Assignment";

async function run() {
    const client = new MongoClient(uri);

    try {
        await client.connect();
        console.log("Connected to MongoDB Atlas");

        const db = client.db("Assign6");
        const students = db.collection("students");

        // 1️ Update CGPA of a specific student (e.g., student_id = S002)
        const updateCGPAResult = await students.updateOne(
            { student_id: "S002" }, // filter
            { $set: { cgpa: 9.0 } } // new CGPA
        );
        console.log(`Updated CGPA for S002 — modifiedCount: ${updateCGPAResult.modifiedCount}`);

        // 2️ Increase year of all 3rd-year students by 1
        const increaseYearResult = await students.updateMany(
            { year: 3 }, // filter
            { $inc: { year: 1 } } // increment year by 1
        );
        console.log(`Increased year for ${increaseYearResult.modifiedCount} student(s)`);

        // Display updated collection
        const updatedStudents = await students.find().toArray();
        console.log("\nUpdated Students Collection:");
        console.table(updatedStudents.map(s =&amp;gt; ({
            student_id: s.student_id,
            name: s.name,
            year: s.year,
            cgpa: s.cgpa
        })));

    } catch (err) {
        console.error("Error:", err);
    } finally {
        await client.close();
        console.log("Connection closed.");
    }
}

run();
&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%2Ffn8sb5yn4psgqdgi8a25.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%2Ffn8sb5yn4psgqdgi8a25.png" alt=" " width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Delete
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Delete one student record by student_id.&lt;/li&gt;
&lt;li&gt;Delete all students having CGPA &amp;lt; 7.5.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { MongoClient } = require("mongodb");

const uri = "mongodb+srv://William:4dwQ454VgRgDtNSO@assignment.jfmqse7.mongodb.net/?retryWrites=true&amp;amp;w=majority&amp;amp;appName=Assignment";

async function run() {
  const client = new MongoClient(uri);

  try {
    await client.connect();
    console.log("Connected to MongoDB Atlas");

    const db = client.db("Assign6");
    const students = db.collection("students");

    // Delete one student record by student_id (example: S004)
    const deleteOneResult = await students.deleteOne({ student_id: "S004" });
    console.log("Deleted student S004 — deletedCount:", deleteOneResult.deletedCount);

    // Delete all students having CGPA &amp;lt; 7.5
    const deleteManyResult = await students.deleteMany({ cgpa: { $lt: 7.5 } });
    console.log("Deleted students with CGPA &amp;lt; 7.5 — deletedCount:", deleteManyResult.deletedCount);

    // Display remaining collection
    const remainingStudents = await students.find().toArray();
    console.log("Remaining Students Collection:");
    console.table(remainingStudents.map(s =&amp;gt; ({
      student_id: s.student_id,
      name: s.name,
      year: s.year,
      cgpa: s.cgpa
    })));

  } catch (err) {
    console.error("Error:", err);
  } finally {
    await client.close();
    console.log("Connection closed.");
  }
}

run();

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

</description>
    </item>
    <item>
      <title>Indexing, Hashing &amp; Query Optimization</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Tue, 07 Oct 2025 06:06:47 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/indexing-hashing-query-optimization-2560</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/indexing-hashing-query-optimization-2560</guid>
      <description>&lt;h2&gt;
  
  
  Create a table Students
&lt;/h2&gt;

&lt;p&gt;Create a table Students with fields (roll_no, name, dept, cgpa)&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 Students (
  roll_no INT PRIMARY KEY,
  name    VARCHAR2(50),
  dept    VARCHAR2(10),
  cgpa    NUMBER(3,2)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insert at least 20 sample records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
  INSERT INTO Students VALUES (101, 'Aarav', 'CSBS', 8.5);
  INSERT INTO Students VALUES (102, 'Meera', 'ECE', 7.8);
  INSERT INTO Students VALUES (103, 'Ravi', 'MECH', 6.9);
  INSERT INTO Students VALUES (104, 'Lakshmi', 'CSBS', 9.1);
  INSERT INTO Students VALUES (105, 'Kiran', 'EEE', 7.5);
  INSERT INTO Students VALUES (106, 'Divya', 'CIVIL', 8.2);
  INSERT INTO Students VALUES (107, 'Vishal', 'CSBS', 8.9);
  INSERT INTO Students VALUES (108, 'Sneha', 'ECE', 7.2);
  INSERT INTO Students VALUES (109, 'Rahul', 'MECH', 6.8);
  INSERT INTO Students VALUES (110, 'Priya', 'CSBS', 9.3);
  INSERT INTO Students VALUES (111, 'Anjali', 'EEE', 7.4);
  INSERT INTO Students VALUES (112, 'Manoj', 'CIVIL', 8.0);
  INSERT INTO Students VALUES (113, 'Neha', 'CSBS', 8.7);
  INSERT INTO Students VALUES (114, 'Arjun', 'ECE', 7.6);
  INSERT INTO Students VALUES (115, 'Pooja', 'MECH', 6.5);
  INSERT INTO Students VALUES (116, 'Suresh', 'EEE', 7.9);
  INSERT INTO Students VALUES (117, 'Geeta', 'CIVIL', 8.3);
  INSERT INTO Students VALUES (118, 'Tarun', 'CSBS', 9.0);
  INSERT INTO Students VALUES (119, 'Bhavna', 'ECE', 7.1);
  INSERT INTO Students VALUES (120, 'Nikhil', 'MECH', 6.7);
  COMMIT;
END;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  B-Tree index
&lt;/h2&gt;

&lt;p&gt;Create a B-Tree index on the roll_no column of the Students table.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Oracle automatically creates a unique B-Tree index on any column declared as PRIMARY KEY&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  fetch the details
&lt;/h2&gt;

&lt;p&gt;Execute a query to fetch the details of a student with roll_no = 110.&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 Students WHERE roll_no = 110;

&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%2Fcb1lvbp5b4kmyuweexxy.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%2Fcb1lvbp5b4kmyuweexxy.png" alt=" " width="653" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  B+ Tree index
&lt;/h2&gt;

&lt;p&gt;Create a B+ Tree index on the cgpa column of the Students table.&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_cgpa ON Students(cgpa);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  display
&lt;/h2&gt;

&lt;p&gt;Write a query to display all students with cgpa &amp;gt; 8.0.&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%2Fbnwu6occm3m3idhvgarw.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%2Fbnwu6occm3m3idhvgarw.png" alt=" " width="263" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hash index
&lt;/h2&gt;

&lt;p&gt;Create a Hash index on the dept column of the Students table.&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_dept_hash ON Students(UPPER(dept));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  display
&lt;/h2&gt;

&lt;p&gt;Run a query to retrieve all students from the 'CSBS' department.&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 Students WHERE UPPER(dept) = '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%2Fj215ldc6u3s84xkkgwo2.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%2Fj215ldc6u3s84xkkgwo2.png" alt=" " width="651" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Transactions, Deadlocks &amp; Log Based Recovery</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Tue, 07 Oct 2025 06:03:52 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/transactions-deadlocks-log-based-recovery-1ddl</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/transactions-deadlocks-log-based-recovery-1ddl</guid>
      <description>&lt;h2&gt;
  
  
  Schema
&lt;/h2&gt;

&lt;p&gt;Use a single table Accounts:&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
);

INSERT INTO Accounts VALUES
(1, 'Alice', 1000),
(2, 'Bob', 1500),
(3, 'Charlie', 2000);
&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%2Fjklwhmxqe23kv3f4o3yw.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%2Fjklwhmxqe23kv3f4o3yw.png" alt=" " width="513" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Transaction – Atomicity &amp;amp; Rollback
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Start a transaction to transfer 500 from Alice to Bob.&lt;/li&gt;
&lt;li&gt;Rollback the transaction before committing.&lt;/li&gt;
&lt;li&gt;Check balances to ensure no partial update happened.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
  -- Start transaction
  UPDATE Accounts SET balance = balance - 500 WHERE acc_no = 1; -- Alice
  UPDATE Accounts SET balance = balance + 500 WHERE acc_no = 2; -- Bob

  -- Rollback before committing
  ROLLBACK;

  -- Check balances
  DECLARE
    v_alice INT;
    v_bob INT;
  BEGIN
    SELECT balance INTO v_alice FROM Accounts WHERE acc_no = 1;
    SELECT balance INTO v_bob FROM Accounts WHERE acc_no = 2;

    DBMS_OUTPUT.PUT_LINE('Alice balance: ' || v_alice);
    DBMS_OUTPUT.PUT_LINE('Bob balance: ' || v_bob);
  END;
END;

&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%2Fi44tma2393cjodvecjpz.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%2Fi44tma2393cjodvecjpz.png" alt=" " width="510" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deadlock Simulation (using two browser tabs in Live SQL)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open two sessions.&lt;/li&gt;
&lt;li&gt;Session 1: Lock Alice’s account and try to update Bob’s.&lt;/li&gt;
&lt;li&gt;Session 2: Lock Bob’s account and try to update Alice’s.&lt;/li&gt;
&lt;li&gt;Observe deadlock.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- SESSION 1
-- Lock Alice
UPDATE Accounts SET balance = balance + 100 WHERE acc_no = 1;

-- updating Bob (will wait if Bob is locked)
UPDATE Accounts SET balance = balance - 100 WHERE acc_no = 2;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- SESSION 2
-- Lock Bob
UPDATE Accounts SET balance = balance + 100 WHERE acc_no = 2;

-- updating Alice (will wait if Alice is locked)
UPDATE Accounts SET balance = balance - 100 WHERE acc_no = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Checking Output
DECLARE
  v_alice INT;
  v_bob INT;
BEGIN
  SELECT balance INTO v_alice FROM Accounts WHERE acc_no = 1;
  SELECT balance INTO v_bob FROM Accounts WHERE acc_no = 2;

  DBMS_OUTPUT.PUT_LINE('Alice balance: ' || v_alice);
  DBMS_OUTPUT.PUT_LINE('Bob balance: ' || v_bob);
END;

&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%2Fokrywsawo1zek2f83m30.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%2Fokrywsawo1zek2f83m30.png" alt=" " width="184" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Enable logging (if using MySQL/PostgreSQL, binary log/WAL is default).&lt;/li&gt;
&lt;li&gt;Start a transaction to update a record and rollback.&lt;/li&gt;
&lt;li&gt;Check the log to confirm undo operation was recorded.
&lt;/li&gt;
&lt;/ul&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 + 100 WHERE acc_no = 3;
ROLLBACK;
&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%2Fp0b15lh1oqsc5gh25t2x.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%2Fp0b15lh1oqsc5gh25t2x.png" alt=" " width="513" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ACID property with SQL transactions</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Tue, 07 Oct 2025 06:00:22 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/acid-property-with-sql-transactions-2015</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/acid-property-with-sql-transactions-2015</guid>
      <description>&lt;h3&gt;
  
  
  Create a table Accounts(acc_no INT PRIMARY KEY, name VARCHAR(50), balance INT). Insert 3 sample rows.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Creating Account table
CREATE TABLE Accounts (
  acc_no   INT PRIMARY KEY,
  name     VARCHAR2(50),
  balance  INT CHECK (balance &amp;gt;= 0)  -- Enforces Consistency
);

-- Inserting values
BEGIN
  INSERT INTO Accounts VALUES (101, 'Aarav', 50000);
  INSERT INTO Accounts VALUES (102, 'Meera', 60000);
  INSERT INTO Accounts VALUES (103, 'Ravi', 70000);
  COMMIT;
END;

SELECT * FROM Accounts;
&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%2Fxkqr1jlecteiun4m43ey.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%2Fxkqr1jlecteiun4m43ey.png" alt=" " width="511" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Atomicity: Start a transaction that transfers money. Rollback midway → ensure no partial update remains.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
  -- Atomic transaction: transfer money
  UPDATE Accounts SET balance = balance - 10000 WHERE acc_no = 101;
  UPDATE Accounts SET balance = balance + 10000 WHERE acc_no = 102;

  -- Show updated balances
  DECLARE
    v_bal_101 INT;
    v_bal_102 INT;
  BEGIN
    SELECT balance INTO v_bal_101 FROM Accounts WHERE acc_no = 101;
    SELECT balance INTO v_bal_102 FROM Accounts WHERE acc_no = 102;

    DBMS_OUTPUT.PUT_LINE('Account 101 balance: ' || v_bal_101);
    DBMS_OUTPUT.PUT_LINE('Account 102 balance: ' || v_bal_102);
  END;

  -- Rollback to test atomicity
  ROLLBACK;
END;
&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%2Fgha2v6bqgqfzerbzj97r.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%2Fgha2v6bqgqfzerbzj97r.png" alt=" " width="518" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Consistency: Try inserting a record with negative balance → should be rejected.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
  -- Try inserting invalid data
  INSERT INTO Accounts VALUES (104, 'Lakshmi', -5000);  -- Violates CHECK constraint
  COMMIT;
END;
&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%2F0du88cijs88h9h90hykx.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%2F0du88cijs88h9h90hykx.png" alt=" " width="578" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Isolation: Run two sessions at once – one updating, the other reading → observe isolation.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Session A (Updater)
BEGIN
  UPDATE Accounts SET balance = balance + 5000 WHERE acc_no = 103;
  -- Do NOT commit yet
END;

-- Session B (Reader)
SELECT * FROM Accounts WHERE acc_no = 103;
&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%2F9zhag3pg6lqh13po1keo.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%2F9zhag3pg6lqh13po1keo.png" alt=" " width="515" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Durability: Commit a transaction → restart DB → ensure data persists.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Commit and Restart
BEGIN
  UPDATE Accounts SET balance = balance + 10000 WHERE acc_no = 102;
  COMMIT;
END;

-- After DB restart
SELECT * FROM Accounts WHERE acc_no = 102;
&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%2Fi7eby29h2856wd2h0iz2.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%2Fi7eby29h2856wd2h0iz2.png" alt=" " width="511" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Cursor + Trigger Assignment</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Tue, 07 Oct 2025 05:58:57 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/cursor-trigger-assignment-2po9</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/cursor-trigger-assignment-2po9</guid>
      <description>&lt;h2&gt;
  
  
  Cursor with Condition
&lt;/h2&gt;

&lt;p&gt;Quesn: Create a cursor that displays employee names whose salary is greater than 50,000 from the Employee table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Creating the table
CREATE TABLE Employee (
  emp_id     NUMBER PRIMARY KEY,
  emp_name   VARCHAR2(100),
  salary     NUMBER
);

-- Initialising the table
BEGIN
  INSERT INTO Employee VALUES (1, 'Alice', 45000);
  INSERT INTO Employee VALUES (2, 'Bob', 52000);
  INSERT INTO Employee VALUES (3, 'Charlie', 60000);
  INSERT INTO Employee VALUES (4, 'Diana', 48000);
  INSERT INTO Employee VALUES (5, 'Ethan', 75000);
  COMMIT;
END;

SELECT * FROM Employee;
&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%2Fvs7iqp6sqoaog3gbuc92.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%2Fvs7iqp6sqoaog3gbuc92.png" alt=" " width="512" height="201"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Creating the cursor and giving output
DECLARE
  CURSOR high_salary_cursor IS
    SELECT emp_name FROM Employee WHERE salary &amp;gt; 50000;

  v_name Employee.emp_name%TYPE;
BEGIN
  FOR emp_rec IN high_salary_cursor LOOP
    DBMS_OUTPUT.PUT_LINE('Employee: ' || emp_rec.emp_name);
  END LOOP;
END;
&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%2F22b0z591fihoo72x2w8b.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%2F22b0z591fihoo72x2w8b.png" alt=" " width="272" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AFTER INSERT Trigger (Student Table)
&lt;/h2&gt;

&lt;p&gt;Quesn: Whenever a new student is added to the Students table, we want to automatically insert a log entry into the Student_Audit table to keep track of the registration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Creating table Students
CREATE TABLE Students (
  student_id   NUMBER PRIMARY KEY,
  student_name VARCHAR2(100),
  course       VARCHAR2(50)
);

-- Creating  Audit table for tracking registrations
CREATE TABLE Student_Audit (
  audit_id     NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  student_id   NUMBER,
  student_name VARCHAR2(100),
  registration_date DATE
);

-- Inserting sample data into students table
BEGIN
  INSERT INTO Students (student_id, student_name, course) VALUES (1, 'Aarav', 'Physics');
  INSERT INTO Students (student_id, student_name, course) VALUES (2, 'Meera', 'Chemistry');
  INSERT INTO Students (student_id, student_name, course) VALUES (3, 'Ravi', 'Mathematics');
  COMMIT;
END;

SELECT * FROM Students;
&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%2Fitgc8t93cxic6199ivao.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%2Fitgc8t93cxic6199ivao.png" alt=" " width="513" height="199"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Creating the AFTER INSERT Trigger
CREATE OR REPLACE TRIGGER trg_student_registration
AFTER INSERT ON Students
FOR EACH ROW
BEGIN
  INSERT INTO Student_Audit (student_id, student_name, registration_date)
  VALUES (:NEW.student_id, :NEW.student_name, SYSDATE);
END;

-- Testing the trigger
BEGIN
  INSERT INTO Students (student_id, student_name, course) VALUES (4, 'Lakshmi', 'Biology');
  COMMIT;
END;

-- Viewing the Audit log
SELECT * FROM Student_Audit;
&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%2Ffmnrp5ns80p96rigcn9b.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%2Ffmnrp5ns80p96rigcn9b.png" alt=" " width="698" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Normalisation Assignment</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Tue, 07 Oct 2025 05:50:46 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/normalisation-assignment-47d3</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/normalisation-assignment-47d3</guid>
      <description>&lt;h2&gt;
  
  
  BASE TABLE
&lt;/h2&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%2Fx6sfij82vo67bp0x83za.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%2Fx6sfij82vo67bp0x83za.png" alt=" " width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1NF
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE StudentCourse_1NF (
    StudentID VARCHAR(10),
    StudentName VARCHAR(50),
    CourseID VARCHAR(10),
    CourseName VARCHAR(50),
    Instructor VARCHAR(50),
    InstructorPhone VARCHAR(15),
    PRIMARY KEY (StudentID, CourseID)
);

INSERT INTO StudentCourse_1NF (StudentID, StudentName, CourseID, CourseName, Instructor, InstructorPhone) VALUES
('S01', 'Arjun', 'C101', 'DBMS', 'Dr. Kumar', '9876543210'),
('S01', 'Arjun', 'C102', 'Data Mining', 'Dr. Mehta', '9123456780'),
('S02', 'Priya', 'C101', 'DBMS', 'Dr. Kumar', '9876543210'),
('S03', 'Kiran', 'C103', 'AI', 'Dr. Rao', '9988776655');

SELECT * FROM StudentCourse_1NF;
&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%2F55lghh4u45wev48itaxx.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%2F55lghh4u45wev48itaxx.png" alt=" " width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2NF
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--Student Table
CREATE TABLE Student (
    StudentID VARCHAR(10) PRIMARY KEY,
    StudentName VARCHAR(50) NOT NULL
);

INSERT INTO Student VALUES
('S01', 'Arjun'),
('S02', 'Priya'),
('S03', 'Kiran');
&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%2F5b7re31cp50vjz8fdsxv.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%2F5b7re31cp50vjz8fdsxv.png" alt=" " width="733" height="265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Course Table
CREATE TABLE Course (
    CourseID VARCHAR(10) PRIMARY KEY,
    CourseName VARCHAR(50) NOT NULL,
    Instructor VARCHAR(50),
    InstructorPhone VARCHAR(15)
);

INSERT INTO Course VALUES
('C101', 'DBMS', 'Dr. Kumar', '9876543210'),
('C102', 'Data Mining', 'Dr. Mehta', '9123456780'),
('C103', 'AI', 'Dr. Rao', '9988776655');
&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%2Fs1xyj9tfjvjo4t2zqui2.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%2Fs1xyj9tfjvjo4t2zqui2.png" alt=" " width="800" height="150"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Enrollment Table (Junction Table)
CREATE TABLE Enrollment (
    StudentID VARCHAR(10),
    CourseID VARCHAR(10),
    PRIMARY KEY (StudentID, CourseID),
    FOREIGN KEY (StudentID) REFERENCES Student(StudentID),
    FOREIGN KEY (CourseID) REFERENCES Course(CourseID)
);

INSERT INTO Enrollment VALUES
('S01', 'C101'),
('S01', 'C102'),
('S02', 'C101'),
('S03', 'C103');
&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%2Fd5qjq8fxgkyvglp70ngd.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%2Fd5qjq8fxgkyvglp70ngd.png" alt=" " width="737" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3NF
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Student Table
CREATE TABLE Student (
    StudentID VARCHAR(10) PRIMARY KEY,
    StudentName VARCHAR(50) NOT NULL
);

-- Students
INSERT INTO Student VALUES
('S01', 'Arjun'),
('S02', 'Priya'),
('S03', 'Kiran');
&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%2F2rtthfj76of408q13kq1.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%2F2rtthfj76of408q13kq1.png" alt=" " width="800" height="317"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Instructor Table
CREATE TABLE Instructor (
    InstructorID VARCHAR(10) PRIMARY KEY,
    InstructorName VARCHAR(50) NOT NULL,
    InstructorPhone VARCHAR(15)
);

-- Instructors
INSERT INTO Instructor VALUES
('I01', 'Dr. Kumar', '9876543210'),
('I02', 'Dr. Mehta', '9123456780'),
('I03', 'Dr. Rao', '9988776655');

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Course Table
CREATE TABLE Course (
    CourseID VARCHAR(10) PRIMARY KEY,
    CourseName VARCHAR(50) NOT NULL,
    InstructorID VARCHAR(10),
    FOREIGN KEY (InstructorID) REFERENCES Instructor(InstructorID)
);

-- Courses
INSERT INTO Course VALUES
('C101', 'DBMS', 'I01'),
('C102', 'Data Mining', 'I02'),
('C103', 'AI', 'I03');

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Enrollment Table (Junction Table)
CREATE TABLE Enrollment (
    StudentID VARCHAR(10),
    CourseID VARCHAR(10),
    PRIMARY KEY (StudentID, CourseID),
    FOREIGN KEY (StudentID) REFERENCES Student(StudentID),
    FOREIGN KEY (CourseID) REFERENCES Course(CourseID)
);


-- Enrollments
INSERT INTO Enrollment VALUES
('S01', 'C101'),
('S01', 'C102'),
('S02', 'C101'),
('S03', 'C103');
&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%2Fgqwy2yhzhxesw6b31xw8.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%2Fgqwy2yhzhxesw6b31xw8.png" alt=" " width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  USING JOIN
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    s.StudentName,
    c.CourseName,
    i.InstructorName
FROM Enrollment e
JOIN Student s ON e.StudentID = s.StudentID
JOIN Course c ON e.CourseID = c.CourseID
JOIN Instructor i ON c.InstructorID = i.InstructorID
ORDER BY s.StudentName;
&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%2Fvaw1jubk682vh0ho5xbq.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%2Fvaw1jubk682vh0ho5xbq.png" alt=" " width="800" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>LiveSQL Assignment - College Student &amp; Course Management System</title>
      <dc:creator>GWEDE WILLIAM RUKUDZO 24CB065</dc:creator>
      <pubDate>Thu, 21 Aug 2025 19:26:15 +0000</pubDate>
      <link>https://dev.to/gwede_williamrukudzo24c/livesql-assignment-college-student-course-management-system-3m04</link>
      <guid>https://dev.to/gwede_williamrukudzo24c/livesql-assignment-college-student-course-management-system-3m04</guid>
      <description>&lt;p&gt;Working with SQL is one of the most effective ways to understand how real-world data management systems work. For this project, I used Oracle LiveSQL to implement and test queries for a College Student &amp;amp; Course Management System.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Case: College Student &amp;amp; Course Management System
&lt;/h2&gt;

&lt;p&gt;-- Student table&lt;br&gt;
CREATE TABLE Students (&lt;br&gt;
    StudentID NUMBER PRIMARY KEY,&lt;br&gt;
    Name VARCHAR2(50) NOT NULL,&lt;br&gt;
    Dept VARCHAR2(30),&lt;br&gt;
    DOB DATE,&lt;br&gt;
    Email VARCHAR2(50) UNIQUE&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;-- Courses table&lt;br&gt;
CREATE TABLE Courses (&lt;br&gt;
    CourseID NUMBER PRIMARY KEY,&lt;br&gt;
    CourseName VARCHAR2(50) NOT NULL,&lt;br&gt;
    Credits NUMBER(2)&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;-- Enrollments table (Many-to-Many relationship)&lt;br&gt;
CREATE TABLE Enrollments (&lt;br&gt;
    EnrollID NUMBER PRIMARY KEY,&lt;br&gt;
    StudentID NUMBER REFERENCES Students(StudentID),&lt;br&gt;
    CourseID NUMBER REFERENCES Courses(CourseID),&lt;br&gt;
    Grade CHAR(2)&lt;br&gt;
);&lt;/p&gt;

&lt;h2&gt;
  
  
  1. DDL – Creating the Faculty Table
&lt;/h2&gt;

&lt;p&gt;The first task was to create a new table for faculty members. The table includes a primary key, a unique email constraint, and ensures the FacultyName cannot be null.&lt;/p&gt;

&lt;p&gt;CREATE TABLE Faculty (&lt;br&gt;
    FacultyID NUMBER PRIMARY KEY,&lt;br&gt;
    FacultyName VARCHAR2(50) NOT NULL,&lt;br&gt;
    Dept VARCHAR2(30),&lt;br&gt;
    Email VARCHAR2(50) UNIQUE&lt;br&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%2F10mq938q00bh7chqz9n9.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%2F10mq938q00bh7chqz9n9.png" alt=" " width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. DML – Insert Data
&lt;/h2&gt;

&lt;p&gt;Insert three students into the Students table with different departments.&lt;/p&gt;

&lt;p&gt;INSERT INTO Students (StudentID, Name, Dept, DOB, Email)&lt;br&gt;
  VALUES&lt;br&gt;
    (1, 'John Smith', 'Computer Science', TO_DATE('2002-03-15', 'YYYY-MM-DD'), '&lt;a href="mailto:john.smith@university.edu"&gt;john.smith@university.edu&lt;/a&gt;'),&lt;br&gt;
    (2, 'Emma Johnson', 'Mathematics', TO_DATE('2001-07-22', 'YYYY-MM-DD'), '&lt;a href="mailto:emma.johnson@university.edu"&gt;emma.johnson@university.edu&lt;/a&gt;'),&lt;br&gt;
    (3, 'Michael Chen', 'Physics', TO_DATE('2003-01-10', 'YYYY-MM-DD'), '&lt;a href="mailto:michael.chen@university.edu"&gt;michael.chen@university.edu&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%2Fufcehaomlay72vfgko6e.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%2Fufcehaomlay72vfgko6e.png" alt=" " width="800" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Alter Table
&lt;/h2&gt;

&lt;p&gt;Add a new column PhoneNo to the Students table, ensuring it can store 10-digit numbers.&lt;/p&gt;

&lt;p&gt;ALTER TABLE Students &lt;br&gt;
ADD PhoneNo NUMBER(10);&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%2F0sxkaha4mzndycwyr2d8.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%2F0sxkaha4mzndycwyr2d8.png" alt=" " width="438" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Defining Constraints
&lt;/h2&gt;

&lt;p&gt;Modify the Courses table so that Credits cannot be less than 1 or more than 5.&lt;/p&gt;

&lt;p&gt;ALTER TABLE Courses&lt;br&gt;
MODIFY (Credits CONSTRAINT chk_credits CHECK (Credits BETWEEN 1 AND 5));&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%2Fe9jmz7mgjkcsgxa67eqr.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%2Fe9jmz7mgjkcsgxa67eqr.png" alt=" " width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. SELECT with Functions
&lt;/h2&gt;

&lt;p&gt;Display the names of students in uppercase and show the length of their email IDs.&lt;/p&gt;

&lt;p&gt;SELECT UPPER(Name) AS StudentName, &lt;br&gt;
       LENGTH(Email) AS EmailLength&lt;br&gt;
FROM Students;&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%2Fgbh50rey03iqoot61qpn.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%2Fgbh50rey03iqoot61qpn.png" alt=" " width="741" height="727"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Aggregate Functions
&lt;/h2&gt;

&lt;p&gt;Find the average credits of all courses and the total number of students enrolled.&lt;/p&gt;

&lt;p&gt;SELECT AVG(Credits) AS AvgCredits FROM Courses;&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%2Fsiqmmyravjrax706nhi8.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%2Fsiqmmyravjrax706nhi8.png" alt=" " width="457" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SELECT COUNT(*) AS TotalStudents FROM Students;&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%2Fyulrxjidrks2ae8m8mmu.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%2Fyulrxjidrks2ae8m8mmu.png" alt=" " width="458" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. JOIN Operation
&lt;/h2&gt;

&lt;p&gt;List all students along with the courses they are enrolled in (Student Name, Course Name, Grade).&lt;/p&gt;

&lt;p&gt;SELECT s.Name AS StudentName, &lt;br&gt;
       c.CourseName, &lt;br&gt;
       e.Grade&lt;br&gt;
FROM Students s&lt;br&gt;
JOIN Enrollments e ON s.StudentID = e.StudentID&lt;br&gt;
JOIN Courses c ON e.CourseID = c.CourseID;&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%2Fy6n8s3y5nd37qib7aoah.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%2Fy6n8s3y5nd37qib7aoah.png" alt=" " width="800" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. GROUP BY with HAVING
&lt;/h2&gt;

&lt;p&gt;Show each department and the count of students. Display only those departments with more than 2 students.&lt;/p&gt;

&lt;p&gt;BEFORE FILTERING&lt;br&gt;
SELECT Dept, COUNT(&lt;em&gt;) AS StudentCount&lt;br&gt;
FROM Students&lt;br&gt;
GROUP BY Dept&lt;br&gt;
HAVING COUNT(&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%2Ff7wqli7hc4rg5ytzjcng.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%2Ff7wqli7hc4rg5ytzjcng.png" alt=" " width="744" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AFTER FILTERING&lt;br&gt;
SELECT Dept, COUNT(&lt;em&gt;) AS StudentCount&lt;br&gt;
FROM Students&lt;br&gt;
GROUP BY Dept&lt;br&gt;
HAVING COUNT(&lt;/em&gt;) &amp;gt; 2;&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%2Fcu3mi50i49a1x4bhhu04.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%2Fcu3mi50i49a1x4bhhu04.png" alt=" " width="575" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Views
&lt;/h2&gt;

&lt;p&gt;Create a view called StudentCoursesView that shows: StudentName, CourseName, Grade.&lt;/p&gt;

&lt;p&gt;CREATE VIEW StudentCoursesView AS&lt;br&gt;
SELECT s.Name AS StudentName, &lt;br&gt;
       c.CourseName, &lt;br&gt;
       e.Grade&lt;br&gt;
FROM Students s&lt;br&gt;
JOIN Enrollments e ON s.StudentID = e.StudentID&lt;br&gt;
JOIN Courses c ON e.CourseID = c.CourseID;&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%2F2tuhvnwce3ie9963tucd.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%2F2tuhvnwce3ie9963tucd.png" alt=" " width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Stored Procedure
&lt;/h2&gt;

&lt;p&gt;Write a procedure UpdateGrade that updates a student’s grade in the Enrollments table given StudentID, CourseID, and the NewGrade.&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;
BEGIN&lt;br&gt;
    UPDATE Enrollments&lt;br&gt;
    SET Grade = p_NewGrade&lt;br&gt;
    WHERE StudentID = p_StudentID AND CourseID = p_CourseID;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COMMIT;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;END;&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%2F40p5m59kk0qtzuhgzsux.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%2F40p5m59kk0qtzuhgzsux.png" alt=" " width="568" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;This project gave me hands-on experience with SQL concepts such as DDL, DML, constraints, functions, joins, grouping, views, and stored procedures using Oracle LiveSQL. By building a College Student &amp;amp; Course Management System, I learned how different SQL features come together in practical database applications.&lt;/p&gt;

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