CSC 282 · Database Programming
Our notes
2 min readINSERT
INSERT INTO department (dept_code, dept_name)
VALUES ('CSC', 'Computer Science');
INSERT INTO student (matric_no, surname, other_names, dept_code, level)
VALUES ('U2024/5570001', 'Okoro', 'Ada', 'CSC', 200),
('U2024/5570002', 'Bello', 'Musa', 'CSC', 200);
List the columns: the statement keeps working if a column is added later. A row that breaks a constraint (duplicate key, missing department, score 120) is refused.
UPDATE
UPDATE student SET level = 300
WHERE matric_no = 'U2024/5570001';
UPDATE result SET score = score + 2
WHERE course_code = 'STA 260' AND session = '2025/2026';
Without WHERE, every row changes. Run the matching SELECT first to see which rows will be affected.
DELETE
DELETE FROM result
WHERE course_code = 'CSC 282' AND session = '2019/2020';
Without WHERE, every row goes (the table stays). A delete that would break referential integrity is refused unless the foreign key says ON DELETE CASCADE.
NULL
NULL means "unknown or not applicable", not zero or empty text.
- Test with IS NULL / IS NOT NULL (score = NULL is never true).
- Aggregates ignore NULLs: AVG over 60, 80 and NULL is 70, but COUNT(*) is 3 while COUNT(score) is 2.
Transactions
A transaction is a group of statements that must succeed or fail together. Moving ₦5,000 between two wallets:
START TRANSACTION;
UPDATE wallet SET balance = balance - 5000 WHERE owner = 'A';
UPDATE wallet SET balance = balance + 5000 WHERE owner = 'B';
COMMIT;
If anything fails, ROLLBACK undoes both updates.
ACID
- Atomicity: all or nothing.
- Consistency: the database moves from one valid state to another (rules hold).
- Isolation: concurrent transactions do not see each other's half-finished work.
- Durability: once committed, changes survive a crash.
Concurrency problems a DBMS prevents
- Lost update: two clerks read balance 10,000, both add a payment, the second write overwrites the first.
- Dirty read: reading another transaction's uncommitted change that is later rolled back.
DBMSs use locks or row versions to keep transactions isolated.
Exams usually ask
- Write INSERT, UPDATE and DELETE for a scenario.
- Explain a transaction and the ACID properties with a bank example.
- Explain NULL and its effect on aggregates.
Common mistake
Writing WHERE score = NULL. Use WHERE score IS NULL.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Data manipulation language
(opens en.wikipedia.org in a new tab)
Wikipedia, Data manipulation language, CC BY-SA 4.0 · licence
-
Database transaction
(opens en.wikipedia.org in a new tab)
Wikipedia, Database transaction, CC BY-SA 4.0 · licence
-
ACID
(opens en.wikipedia.org in a new tab)
Wikipedia, ACID, CC BY-SA 4.0 · licence
-
NOUN CIT 304: Data Management
NOUN course book (PDF, about 6.9 MB: best on Wi-Fi). Files, databases, the relational model and SQL.
(opens nou.edu.ng in a new tab)
Watch
-
Best pick DML Commands - INSERT and UPDATE
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
SQL DML Commands (Visually Explained) | INSERT, UPDATE, DELETE | #SQL Course 6
25 min · ≈ 113 MB · about ₦63
(opens youtube.com in a new tab)
-
Intermediate SQL Tutorial | Updating/Deleting Data
5 min · ≈ 23 MB · about ₦13
(opens youtube.com in a new tab)
-
How to Create Table, Insert Update Delete, Join in Sql Server Management Studio | SQL for Beginners
25 min · ≈ 113 MB · about ₦63
(opens youtube.com in a new tab)
-
Database Management System | SQL - Insert, Update & Delete operations, Joins, Unions, Minus|
31 min · ≈ 140 MB · about ₦79
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.