Show understanding of how the software tools provided by a DBMS are used in practice.
| File‑based system | Relational DBMS |
|---|---|
| Data stored in separate, unrelated files → high redundancy | Data stored in tables with a central data dictionary → eliminates duplication |
| No built‑in integrity checks → inconsistent or illegal data | Integrity constraints (PK, FK, UNIQUE, NOT NULL, CHECK) enforce consistency automatically |
| Application‑specific file formats → difficult to share data | Logical schema separates design from physical storage → data independence |
| Concurrency handled manually → risk of lost updates, deadlocks | DBMS provides concurrency control (locks, MVCC) and guarantees ACID properties |
| No central security model → ad‑hoc file permissions only | Authentication, authorisation, row‑level security built in |
| Backup & recovery must be scripted manually | Standardised backup types (full, incremental, differential) and point‑in‑time recovery |
Most DBMSs ship with a graphical or command‑line IDE (e.g. MySQL Workbench, pgAdmin, Oracle SQL Developer). Typical tasks:
EXPLAIN (or equivalent).Query‑processor pipeline (simplified)
Parser → Optimiser → Executor
| | |
Syntax Choose best Perform I/O,
checking access path apply operators,
resolve (indexes, return rows
names) joins)
CREATE SCHEMA – group related objects.CREATE TABLE – define columns, data types, and constraints.ALTER TABLE – add/modify/drop columns, constraints, indexes.DROP TABLE / SCHEMA – remove objects.CREATE INDEX – improve search performance.CREATE SCHEMA Retail AUTHORIZATION dbo;CREATE TABLE Retail.Employee (
EmpID INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
DeptID INT NOT NULL,
Salary DECIMAL(10,2) CHECK (Salary >= 0),
CONSTRAINT fk_dept FOREIGN KEY (DeptID)
REFERENCES Retail.Department(DeptID)
);
ALTER TABLE Employee ADD HireDate DATE;DROP INDEX idx_salary ON Employee;CREATE UNIQUE INDEX uqempname ON Employee(Name);INSERT INTO Retail.Employee (EmpID, Name, DeptID, Salary)VALUES (101, 'Alice Brown', 3, 48000.00);
UPDATE Retail.Employee
SET Salary = Salary * 1.05
WHERE EmpID = 101;
DELETE FROM Retail.Employee
WHERE EmpID = 101;
SELECT e.Name,d.DeptName,
e.Salary,
COUNT(s.SaleID) AS SalesCount,
SUM(s.Amount) AS TotalSales
FROM Retail.Employee e
JOIN Retail.Department d ON e.DeptID = d.DeptID
LEFT JOIN Retail.Sales s ON e.EmpID = s.EmpID
WHERE e.Salary > 50000
GROUP BY e.Name, d.DeptName, e.Salary
HAVING COUNT(s.SaleID) > 0
ORDER BY TotalSales DESC;
| JOIN | Result |
|---|---|
| INNER JOIN | Rows that match in both tables |
| LEFT (OUTER) JOIN | All rows from left table + matching rows from right |
| RIGHT (OUTER) JOIN | All rows from right table + matching rows from left |
| FULL (OUTER) JOIN | All rows from both tables |
-- Example of a money transfer (atomic operation)BEGIN TRANSACTION;
UPDATE Retail.Account
SET Balance = Balance - 2000
WHERE AccNo = 'A123';
UPDATE Retail.Account
SET Balance = Balance + 2000
WHERE AccNo = 'B456';
COMMIT; -- or ROLLBACK on error
T1: READ Salary = 50 000
T2: READ Salary = 50 000
T1: UPDATE Salary = 55 000 (5 % raise)
T2: UPDATE Salary = 52 500 (5 % raise) ← overwrites T1’s change
Using SELECT … FOR UPDATE or a higher isolation level prevents this.
-- non‑clustered index on SalaryCREATE INDEX idxempsalary ON Retail.Employee(Salary);
-- clustered index on primary key (often created automatically)
CREATE CLUSTERED INDEX pk_emp ON Retail.Employee(EmpID);
EXPLAIN SELECT * FROM Retail.Employee WHERE Salary > 60000;+----+-------------+----------+------------+------+---------------+------+---------+------+-------+----------+-------+
| id | selecttype | table | partitions | type | possiblekeys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+------+-------+----------+-------+
| 1 | SIMPLE | Employee | NULL | range| idxempsalary| idxempsalary | 4 | NULL | 120 | 30.00 | Using where |
+----+-------------+----------+------------+------+---------------+------+---------+------+-------+----------+-------+
“type = range” and the presence of key = idxempsalary confirm the index is being used.
SELECT statement – no data stored (unless it’s a materialised view, which is optional in some DBMSs).CREATE VIEW Retail.EmpDept ASSELECT EmpID, Name, DeptID
FROM Retail.Employee;
Granting SELECT on EmpDept lets HR staff see names and departments without seeing salaries.
CREATE PROCEDURE Retail.RaiseSalary (IN pDeptID INT,
IN pPct DECIMAL(5,2)
)
BEGIN
UPDATE Retail.Employee
SET Salary = Salary * (1 + pPct/100)
WHERE DeptID = pDeptID;
END;
CREATE FUNCTION Retail.NetSalary (pEmpID INT) RETURNS DECIMAL(10,2)DETERMINISTIC
BEGIN
DECLARE base DECIMAL(10,2);
SELECT Salary INTO base FROM Retail.Employee WHERE EmpID = pEmpID;
RETURN base * 0.80; -- example: 20% tax deduction
END;
CREATE TRIGGER Retail.trgsalaryauditAFTER UPDATE OF Salary ON Retail.Employee
FOR EACH ROW
BEGIN
INSERT INTO Retail.SalaryAudit (EmpID, OldSalary, NewSalary, ChangeDate)
VALUES (OLD.EmpID, OLD.Salary, NEW.Salary, CURRENT_TIMESTAMP);
END;
mysqldump, pg_dump).# Logical full backupmysqldump -u admin -p --single-transaction Retail > Retail_full.sql
# Start a new binary log for incremental backup
mysqladmin -u admin -p flush-logs
# Copy the newly created binlog files (e.g., mysql-bin.000002) to backup storage
CREATE ROLE hr_role;GRANT SELECT, INSERT ON Retail.Employee TO hr_role;
GRANT EXECUTE ON PROCEDURE Retail.RaiseSalary TO hr_role;
GRANT hrrole TO aliceuser;
CREATE POLICY hrsalarypolicy ON Retail.EmployeeFOR SELECT
USING (DeptID = (SELECT DeptID FROM Retail.Department WHERE DeptName = CURRENT_USER));
ALTER TABLE Retail.Employee ENABLE ROW LEVEL SECURITY;
GRANT SELECT ON Retail.Employee TO hr_role;
Many DBMSs ship with basic reporting (MySQL Report, SQL Server Reporting Services) and integrate with external BI platforms such as Power BI, Tableau, or Qlik.
| Task | DBMS Tool(s) Used | Typical Commands / Actions |
|---|---|---|
| Create product catalogue | DDL | CREATE TABLE Retail.Product ( |
| Add new stock | DML – INSERT | INSERT INTO Retail.Product (ProdID, Name, Price, Stock) |
| Record a sale | Transaction Management, DML (INSERT/UPDATE) | BEGIN TRANSACTION; |
| Speed up sales queries | Indexing | CREATE INDEX idxsalesdate ON Retail.Sales (SaleDate); |
| Restrict employee access | Security – roles & row‑level security | CREATE ROLE sales_clerk; |
| Generate monthly sales report | Stored Procedure + Reporting Tool | CREATE PROCEDURE Retail.MonthlySales (IN pMonth INT, IN pYear INT) |
Designers often reason with relational algebra before writing SQL.
σDept='Finance' ∧ Salary>50000(Employee)
The equivalent SQL statement (shown earlier) is:
SELECT Name, SalaryFROM Retail.Employee
WHERE Dept = 'Finance' AND Salary > 50000;
The software tools supplied by a DBMS – data dictionary, DDL, DML, SQL query language, transaction control (ACID), concurrency mechanisms, indexing (clustered & non‑clustered), views, stored procedures, functions, triggers, backup/recovery utilities, layered security (authentication, authorisation, row‑level policies), and reporting/BI integration – work together to create robust, efficient, and secure data‑centric applications. Mastery of these tools enables students to design databases that meet real‑world business requirements while preserving data integrity, performance, and security.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.