Unit 5 Session 3: DBMS Functions | IT 231 Slides

--:-- --
↓ Scroll for more

Unit 5 · Session 3

DBMS Functions

IT 231: IT and Application (BBM)

Learning Objectives 🎯

By the end of this session, you will be able to:

  • ✅ Define a Database Management System (DBMS) and its purpose.
  • ✅ Describe the major functions of a DBMS.
  • ✅ Explain the role of SQL as the language of databases.
  • ✅ Provide examples of popular DBMS.

What is a DBMS?

A Database Management System (DBMS) is a software program that enables users to create, maintain, and control access to a database.

Think of it like a librarian for a huge library:

  • The Library is the Database (stores information).
  • The Books are the Data.
  • The Librarian is the DBMS (manages, organizes, and controls access).

The librarian: the DBMS before computers

A librarian at the issue desk of the Mitchell Library reading room, Sydney, 1943, with readers queueing

🤔 "Can't I Just Use Excel?"

Spreadsheet (Excel)DBMS (e.g. MySQL)
SizeMax 1,048,576 rows per sheetBillions of rows
Many users at onceEdit conflicts, "file is locked"Thousands at the same time, safely
Rules on dataEasy to type "twenty" in an Age columnData types and constraints reject bad data
SecurityWhole file: open or notPermissions per table, even per column
RecoveryHope you saved a copyAutomatic backups and logs

Excel is great for analysis. A DBMS is built for shared, reliable storage.

The DBMS: Your Data Gatekeeper

It acts as an interface between users/applications and the physical database.

Users & Applications

e.g., Website, Mobile App, Analyst

➡️ DBMS ⬅️

(The Manager)

Database

e.g., Tables, Records, Files

The DBMS ensures data is consistently organized and easily accessible, preventing chaos.

Major Functions of a DBMS ⚡

A DBMS handles several critical tasks to manage the database effectively:

  • 📜 Data Definition: Defining the database structure.
  • ✍️ Data Manipulation: Interacting with the data.
  • 🔐 Data Security & Control: Protecting the data.
  • 🔄 Concurrency Control: Managing simultaneous access.
  • 💾 Backup & Recovery: Ensuring data safety.

Function 1: Data Definition (The Blueprint) 📜

The DBMS uses a Data Definition Language (DDL) to build the database's structure.

DDL in Action

This is how an administrator defines the "rules" for the data.

CREATE TABLE Students (
  StudentID INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50),
  EnrollmentDate DATE
);

DDL is used to create tables, define fields, and set constraints.

📜 Worked Example: Rules That Reject Bad Data


CREATE TABLE Orders (
  OrderID    INT PRIMARY KEY,
  Phone      CHAR(10) NOT NULL,
  Amount     DECIMAL(10,2) CHECK (Amount > 0),
  OrderDate  DATE NOT NULL
);
  

Which of these inserts will the DBMS reject?

1. (1, '9841000000', 850.00, '2026-10-15') ✅ Accepted

2. (1, '9851000000', 500.00, '2026-10-15') ❌ OrderID 1 already exists (primary key)

3. (2, '9861000000', -200.00, '2026-10-15') ❌ The amount must be greater than 0 (CHECK)

4. (3, NULL, 300.00, '2026-10-15') ❌ The phone number can't be empty (NOT NULL)

🧮 Normalisation, Step 1: One Value per Cell (1NF)

A college keeps course registrations in one sheet:

101 | Anjali | BBM | Bachelor of Business Management | IT231 Information Technology; MG201 Principles of Management

  • ❌ Two courses in one cell: you can't easily count who takes MG201.
  • 1NF fix: one row per student per course, and one value in each cell.

101 | Anjali | BBM | Bachelor of Business Management | IT231 | Information Technology

101 | Anjali | BBM | Bachelor of Business Management | MG201 | Principles of Management

New problem: Anjali's name and programme now repeat on every row (redundancy).

🧮 Normalisation, Steps 2 and 3: Split by Topic (2NF, 3NF)

The 1NF table's key is StudentID + CourseID.

  • 2NF: every field must depend on the whole key. Name depends only on StudentID, and the course title only on CourseID, so split them out:
    Students(StudentID, Name, ProgrammeCode, ProgrammeName) · Courses(CourseID, Title) · Enrollments(StudentID, CourseID)
  • 3NF: no field may depend on another non-key field. ProgrammeName depends on ProgrammeCode, so move it:
    Programmes(ProgrammeCode, ProgrammeName)

Result: 4 small tables, each fact stored once. Renaming a course now means changing one row, not hundreds.

Function 2: Data Manipulation (The Tools) ✍️

A Data Manipulation Language (DML) allows users to work with the data.

For relational databases, the standard DML is SQL (Structured Query Language).

Core DML Operations:

  • Retrieve (Read)
  • Insert (Create)
  • Update (Modify)
  • Delete (Remove)

Simple SQL Examples:

-- Retrieve data
SELECT * FROM Students;

-- Insert a new record
INSERT INTO Students VALUES (...);

-- Delete a record
DELETE FROM Students WHERE StudentID=101;

🧪 Activity: Write the SQL

Table Products(ProductID, Name, Price, Stock)

1. Show all products cheaper than Rs 1,000.
SELECT * FROM Products WHERE Price < 1000;

2. Add a new product: ID 5, "Dhaka Topi", Rs 1,200, 30 in stock.
INSERT INTO Products VALUES (5, 'Dhaka Topi', 1200, 30);

3. Change the price of product 2 to Rs 950.
UPDATE Products SET Price = 950 WHERE ProductID = 2;

4. Remove every product that is out of stock.
DELETE FROM Products WHERE Stock = 0;

⚠️ If you forget the WHERE in #3 or #4, the change applies to every row!

🎬 Forgetting WHERE

🧮 SQL Walk-Through: Joining Two Tables

Products

1 | Lokta Notebook

2 | Pashmina Shawl

Sales (SaleID, ProductID, Qty)

1 | 1 | 3 · 2 | 2 | 1 · 3 | 1 | 2

SELECT p.Name, s.Qty FROM Sales s JOIN Products p ON s.ProductID = p.ProductID;

  • For each sale, the DBMS finds the product with the same ProductID.
  • Result: Lokta Notebook 3 · Pashmina Shawl 1 · Lokta Notebook 2

🧮 SQL Walk-Through: Totals with GROUP BY

The manager asks: "How many of each product did we sell?" (same tables)


SELECT p.Name, SUM(s.Qty) AS TotalSold
FROM Sales s JOIN Products p ON s.ProductID = p.ProductID
GROUP BY p.Name;
  
  • GROUP BY puts rows with the same name together; SUM adds their quantities.
  • Result: Lokta Notebook 5 (3 + 2), Pashmina Shawl 1
  • Other group functions: COUNT, AVG, MIN, MAX.

Functions 3 & 4: Control & Consistency

🔐 Data Security & Control

The DBMS acts as a security guard.

  • Prevents unauthorized access.
  • Administrators can grant or revoke permissions.
  • Example: A student can view their own grades, but a registrar can view all grades.

🔄 Concurrency Control

Ensures smooth operation in multi-user environments.

  • Prevents conflicts when multiple users try to change the same data at the same time.
  • Imagine two bank tellers trying to update the same account balance simultaneously. The DBMS prevents this from causing errors!

🔐 Worked Example: Who Can See What?

The college stores exam marks in a Results table. The DBA gives each group only the rights it needs.

GRANT SELECT ON Results TO student_portal;
→ The student portal can read marks (and shows each student only their own row).

GRANT SELECT, UPDATE ON Results TO exam_section;
→ The exam section can read and correct marks.

REVOKE UPDATE ON Results FROM exam_section;
→ After results are published, nobody can quietly change a mark.

Rule of thumb: least privilege. Give each user the smallest set of rights that lets them do their job.

🌍 Real Case: The Equifax Breach (2017)

  • Equifax, a US credit-reporting company, ran a web application built on Apache Struts. A security fix for a serious Struts flaw was published in March 2017.
  • Equifax didn't install it. Attackers got in in mid-May and stayed until late July, quietly querying its databases.
  • They took names, birth dates and US Social Security numbers of about 147 million people. Equifax agreed a settlement of up to US$700 million in 2019.

Lesson: GRANT and REVOKE are not enough on their own. Patch quickly, and watch who is reading the data.

🧮 Worked Example: The Lost Update

Hari's balance is Rs 10,000. At the same moment, two transactions run:

Teller A: withdraw Rs 2,000

Reads 10,000

Writes 8,000

Mobile app B: receive Rs 5,000

Reads 10,000

Writes 15,000 (overwrites A!)

Final balance: Rs 15,000. The correct answer is Rs 13,000, so the bank just lost Rs 2,000. A DBMS prevents this with locking: B must wait until A finishes.

What if the power fails halfway through?

Cartoon of Nepal's load-shedding era: a lantern hung on a dark street-light pole

🔒 Transactions: All or Nothing (ACID)

Sending Rs 5,000 from Sita to Ram takes two steps: subtract from Sita, then add to Ram. What if the power fails in between?

A: Atomicity. Both steps happen, or neither does.

C: Consistency. The rules still hold, so the total money stays the same.

I: Isolation. Transactions running at the same time don't interfere (no lost updates).

D: Durability. Once confirmed, it survives a crash.

Every eSewa transfer or bank payment you make is a transaction.

🎬 All or Nothing

Function 5: Backup & Recovery (The Safety Net) 💾

Protects data from loss due to system failures, errors, or disasters.

Backup

The DBMS provides tools to create periodic copies (backups) of the database.

Recovery

If the system crashes, the DBMS can use the backups and transaction logs to restore the database to a consistent state.

This function is absolutely critical for business continuity.

💾 Worked Example: Recovery with a Transaction Log

A bank takes a full backup every Sunday at midnight. The DBMS also writes every change to a transaction log.

  • 💥 Wednesday, 2:00 pm: the main disk fails.
  • 1️⃣ Restore Sunday's backup. The database is now 2½ days old.
  • 2️⃣ Roll forward: replay every completed transaction from the log, Monday to Wednesday 2:00 pm.
  • 3️⃣ Roll back: undo any transaction that was only half-finished at the moment of the crash.

Backup alone: lose 2½ days of payments. Backup + log: lose almost nothing.

🌍 Real Case: GitLab's Five Backups That Failed (2017)

  • 31 January 2017: a tired engineer at GitLab, a code-hosting company, ran a delete command on the wrong database server. It erased about 300 GB of live data.
  • GitLab had five backup or replication methods. When they tried them, none worked as expected.
  • They restored from a copy that happened to be about 6 hours old, so roughly 6 hours of users' work was lost. They even livestreamed the recovery.

Lesson: A backup you've never tested isn't a backup. Remember the 3-2-1 rule from Unit 4: keep 3 copies, on 2 types of media, with 1 off-site.

🌍 Real Case: TSB Bank's Migration Weekend (2018)

  • On 20–22 April 2018, UK bank TSB moved the data of its 5.2 million customers to a new banking platform.
  • The data moved, but the new system failed at once. Up to 1.9 million customers were locked out of online banking, and some saw other people's accounts.
  • Normal service took until December 2018. In 2022 regulators fined TSB £48.65 million for poor planning and testing.

Lesson: changing a database system is risky. Test at full load, move in stages, and keep a way back.

👩‍💻 The Database Administrator (DBA)

The DBMS is the gatekeeper software. The DBA is the person who runs it.

🏗️ Build

Install and upgrade the DBMS, and design tables with the developers.

🔐 Protect

Create user accounts and permissions, and run and test backups.

⚡ Tune

Monitor performance, speed up slow queries, and plan storage growth.

Every Nepali bank, telecom and wallet company employs DBAs. It's a well-paid IT career.

What a DBA Watches: Server Status

MySQL Workbench Server Status screen: management menu for users, privileges, data export and logs, with live connection and traffic graphs

Popular DBMS in the Wild 📊

Different systems are chosen based on cost, scale, and features.

Open-Source

  • MySQL: The world's most popular open-source relational DBMS. Powers much of the web (WordPress, Facebook).
  • PostgreSQL: A powerful, advanced open-source object-relational DBMS known for its reliability and feature set.

Commercial

  • Microsoft SQL Server: A popular and comprehensive commercial DBMS from Microsoft, widely used in enterprise environments.
  • Oracle Database: A leading commercial relational DBMS from Oracle, known for its high performance and scalability in large corporations.

Oracle: from Codd's paper to a database giant

Oracle's headquarters towers at Redwood Shores, California, beside a lagoon

🧪 Activity: Choose the DBMS

1. A small Pokhara homestay wants a cheap booking website. → MySQL or PostgreSQL (free, open-source)

2. A large bank wants its core system with 24/7 vendor support. → Oracle or SQL Server (commercial, supported)

3. A company that already runs everything on Microsoft products. → SQL Server

4. A mobile app that must keep data on the phone while offline. → SQLite, a tiny database built into every Android and iPhone

DBMS in Action: A Nepali Context

Scenario: A Digital Wallet like eSewa or Khalti

How does a DBMS (like PostgreSQL or MySQL) power these services?

  • Data Definition: Defines tables for `Users`, `Transactions`, `Merchants`, and `BankAccounts`.
  • Data Manipulation: When you send money, an `INSERT` statement adds a record to the `Transactions` table, and `UPDATE` statements change the balances in user accounts.

DBMS in Action: A Nepali Context (cont.)

  • Security: Manages your login credentials and ensures you can only access your own transaction history.
  • Concurrency: Safely processes thousands of payments and transfers simultaneously across Nepal without data corruption.
  • Backup: Regularly backs up all transaction data to prevent loss in case of a server failure.

🧪 Case: Design the Database for a College Canteen

The canteen sells items (tea, samosa, chowmein) and records each student's order.

1. Which tables do you need? → Items, Orders, and OrderLines (which items, how many, in each order)

2. What is the primary key of each? → ItemID, OrderID, and OrderID + ItemID together

3. Which DBMS function stops a price of Rs −20? → Data definition: a CHECK (Price > 0) rule

4. Who may change prices? → Only the manager, using GRANT UPDATE (security and control)

5. Two cashiers sell the last samosa at the same moment. Which function helps? → Concurrency control (locking)

⚡ Quick Quiz: DDL or DML?

CREATE TABLE DDL

SELECT DML

ALTER TABLE DDL

UPDATE DML

DROP TABLE DDL

DELETE DML

Bonus: GRANT and REVOKE belong to a third group, DCL (Data Control Language), which manages who can access what.

Summary & Key Takeaways

  • A DBMS is the essential software used to create, manage, and control a database.
  • Its key functions are Data Definition (DDL), Data Manipulation (DML), Security, Concurrency Control, and Backup/Recovery.
  • SQL is the standard language for interacting with relational databases, covering both DDL and DML operations.
  • Popular DBMS include open-source options like MySQL and PostgreSQL, and commercial systems like MS SQL Server and Oracle.

Exam Practice: Short Answer

  1. Define DBMS. Give four examples.
  2. Differentiate between DDL and DML.
  3. Who is a DBA? List three responsibilities.

Exam Practice: Long Answer

  1. Explain the major functions of a DBMS.
  2. What is SQL? Write SQL statements to create a table, insert a record, and retrieve records, and explain each.

Revise the chapter note before writing these answers.

💬 Discussion Questions

  1. Your eSewa transfer shows "failed", but the money left your account. Which ACID property should protect you, and what should happen next?
  2. Why would a bank pay for Oracle when MySQL is free?
  3. After the GitLab story, how would you check that your own phone and laptop backups actually work?

Image & Video Credits

Images

  • "Library desk, Reading Room, Mitchell Building.jpg" (1943): Pix Magazine photographer, State Library of New South Wales, Public domain, via Wikimedia Commons
  • "Cartoon on Load shedding Problem in Nepal..jpg": Basukshitiz9, CC BY-SA 4.0, via Wikimedia Commons
  • "Mysql workbench2.png" (MySQL Workbench server status): screenshot by DnaX, GPL; MySQL Workbench © Oracle, via Wikimedia Commons
  • "Oracle Headquarters Redwood Shores.jpg": Håkan Dahlström, CC BY 2.0, via Wikimedia Commons

Videos (YouTube)

  • Bro Code, "MySQL: How to UPDATE and DELETE data from a TABLE" (2:16–3:23), https://www.youtube.com/watch?v=OB2leB2iZ6U
  • Be A Better Dev, "What is a Database Transaction? Be ACID compliant!" (1:56–3:25), https://www.youtube.com/watch?v=wHUOeXbZCYA

Teaching content © Arjan KC. Third-party media remain the property of their owners.

Thank You!

Any questions?

📖 Read first (chapter notes)