Advanced Database Management: SQL Basics, Queries, and Reports
Subject: Computer Studies Class: Senior Secondary School 3 (SSS 3) Curriculum: NERDC Aligned Topic: Advanced Database Management — Database, SQL Basics, Queries, and Reports
Introduction
Think about JAMB. Every year, millions of Nigerian students register, sit for exams, and receive results within a very short time. Have you ever wondered how all that information — names, scores, schools, states of origin — is stored and retrieved so quickly and accurately? The answer is a database.
Or think a little closer to home. Your school keeps records of every student's name, class, scores, and fees. A hospital in Abuja stores patient history. GTBank processes millions of transactions every single day. All of these depend on databases to work properly.
In today's Nigeria, database management is not just a topic for university students or IT professionals. As an SSS 3 student, learning how databases work — and how to interact with them using SQL — gives you a practical skill that is useful in nearly every field of work, from business and banking to medicine and government.
This lesson takes you beyond the basics. We will explore SQL (Structured Query Language) in detail, learn how to write queries, and understand how reports are generated from databases.
Learning Objectives
By the end of this lesson, you should be able to:
- Define the concept of advanced database management and explain the role of SQL.
- Identify and describe the four main categories of SQL commands.
- Write simple SQL statements to insert, retrieve, update, and delete records.
- Use SQL clauses such as WHERE, ORDER BY, and GROUP BY to refine query results.
- Explain how database reports are generated and why they matter in decision-making.
- Apply ethical and safety principles when working with databases.
Section 1: What Is a Database? (Quick Recap)
A database is an organised collection of related data stored and accessed electronically. Think of it as a very well-arranged school register — every student has a record, every record has a place, and you can find any information quickly without going through everything manually.
Database Management System (DBMS) A DBMS is the software used to create, manage, and interact with a database. Common examples used in Nigerian schools and offices include Microsoft Access, MySQL, Oracle, and SQLite.
In advanced database management, we move beyond simply creating tables. We learn to write precise instructions — called queries — that let us control data exactly the way we need. That is where SQL becomes essential.
Section 2: What Is SQL?
SQL stands for Structured Query Language. It is the standard language used to communicate with relational databases. If a database is a library, then SQL is the language you use to give instructions to the librarian — find me this record, add this new entry, remove that old one, or correct this detail.
Important note: SQL is not a full programming language like Python or Java. It is a query language designed specifically to manage and retrieve structured data. Its commands read almost like plain English, which makes it one of the most beginner-friendly database tools to learn.
The Four Categories of SQL Commands
1. DDL — Data Definition Language Commands: CREATE, ALTER, DROP Purpose: Defines the structure of the database — creating tables, modifying them, or deleting them entirely.
2. DML — Data Manipulation Language Commands: INSERT, UPDATE, DELETE Purpose: Manages the data stored inside the tables — adding, changing, or removing records.
3. DQL — Data Query Language Command: SELECT Purpose: Retrieves data from one or more tables in the database.
4. DCL — Data Control Language Commands: GRANT, REVOKE Purpose: Controls who has access to the database and what they are allowed to do.
Section 3: SQL Basics — The Core Commands
1. CREATE TABLE — Building a New Table
Before you can store any data, you need to create a table. Here is an example that creates a student table for a Nigerian secondary school:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
State VARCHAR(30),
Score INT
);
This creates a table called Students with five columns: StudentID, FirstName, LastName, State (state of origin), and Score.
2. INSERT INTO — Adding Records
To add a student's record into the Students table:
INSERT INTO Students (StudentID, FirstName, LastName, State, Score)
VALUES (1, 'Chukwuemeka', 'Obi', 'Anambra', 78);
3. SELECT — Retrieving Data
The SELECT statement is the most commonly used SQL command. It fetches data from a table.
-- Retrieve all columns for every student
SELECT * FROM Students;
-- Retrieve only names and scores
SELECT FirstName, LastName, Score FROM Students;
4. WHERE — Filtering Results
The WHERE clause narrows down query results to only the records that match a condition. For example, to find all students from Lagos State:
SELECT * FROM Students
WHERE State = 'Lagos';
5. UPDATE — Changing an Existing Record
If a student's score needs to be corrected:
UPDATE Students
SET Score = 85
WHERE StudentID = 1;
6. DELETE — Removing a Record
DELETE FROM Students
WHERE StudentID = 1;
Very important: Always include the WHERE clause when using DELETE or UPDATE. Without it, every single record in the table will be affected. This is one of the most common — and most damaging — mistakes that beginners make.
Section 4: Advanced SQL Queries
ORDER BY — Sorting Results
To display students from the highest score to the lowest:
SELECT FirstName, LastName, Score FROM Students
ORDER BY Score DESC;
Use ASC to sort in ascending order (lowest first) and DESC for descending order (highest first).
GROUP BY — Grouping and Summarising Data
GROUP BY is useful when you want summary information. For example, to count how many students come from each state:
SELECT State, COUNT(*) AS TotalStudents
FROM Students
GROUP BY State;
Aggregate Functions
Aggregate functions perform calculations across multiple rows of data. The five most important ones are:
- COUNT() — counts the number of records
- SUM() — adds up all values in a column
- AVG() — calculates the average value
- MAX() — returns the highest value
- MIN() — returns the lowest value
Example:
-- Calculate the average score of all students
SELECT AVG(Score) AS AverageScore FROM Students;
-- Find the highest score in the table
SELECT MAX(Score) AS TopScore FROM Students;
JOIN — Combining Tables
In real-world databases, information is spread across several tables. A JOIN brings together rows from two or more tables based on a shared column.
-- Join the Students table with a Classes table
SELECT Students.FirstName, Classes.ClassName
FROM Students
INNER JOIN Classes
ON Students.StudentID = Classes.StudentID;
This is especially useful in school management systems where student records, class assignments, and subject scores are stored in separate tables but need to appear together in a report.
Section 5: Database Reports
A database report is a formatted presentation of data that has been retrieved from a database. Reports take raw data and present it in a way that is easy to read and useful for making decisions.
Imagine the principal of a secondary school in Ibadan wants a list of all SS2 students who scored above 70 in Mathematics, arranged from highest to lowest. Instead of searching through piles of paper, the database system can generate that report in seconds.
Types of Database Reports
Tabular Reports Data is presented in rows and columns — similar to a printed result sheet or school register.
Summary Reports Shows totals, averages, and counts — useful for end-of-term performance overviews or school-wide statistics.
Grouped Reports Data is organised by category — for example, student results grouped by subject, class, or gender.
Chart or Graph Reports Data is displayed visually as bar charts, pie charts, or line graphs — helpful for spotting trends and comparing performance over time.
Generating a Report Using SQL
-- Report: Students who scored above 70, arranged highest first
SELECT FirstName, LastName, State, Score
FROM Students
WHERE Score > 70
ORDER BY Score DESC;
In Microsoft Access, you can also use the built-in Report Wizard to design formatted, printable reports without writing any code. This is a practical and beginner-friendly option for most Nigerian school environments.
Section 6: Practical Applications in Nigeria
Database management is actively used across Nigeria every day. Here are some examples students can relate to:
Schools and Examination Bodies WAEC, NECO, and JAMB use large database systems to handle student registration, exam scheduling, result processing, and certificate issuance — all for millions of candidates at once.
Banking GTBank, First Bank, Zenith Bank, and others store customer account details, transaction histories, and loan records in secure, high-speed databases.
Hospitals and Clinics Federal Medical Centres and private hospitals across Nigeria store patient history, prescriptions, test results, and appointment records using database systems.
Retail and Supermarkets Shoprite, Spar, and many local stores use databases to manage inventory, track daily sales, and run customer loyalty programmes.
Logistics and Delivery Companies like GIG Logistics use databases to track packages, monitor drivers, and manage delivery records in real time.
Government Agencies The National Identity Management Commission (NIMC), INEC, and other agencies use databases to store biometric records, voter information, and citizen data.
Section 7: Advantages and Disadvantages of Database Management Systems
Advantages
- Reduces data duplication and redundancy across the organisation
- Makes data retrieval fast, accurate, and consistent
- Allows multiple users to access and work with data at the same time
- Provides strong security features including passwords, access levels, and encryption
- Supports the generation of reports that help organisations make better decisions
- Makes it easy to back up and restore data when problems occur
Disadvantages
- Can be expensive to purchase, set up, and maintain
- Requires trained and skilled personnel to manage properly
- A system failure or server crash can affect all users simultaneously
- Databases that store sensitive data are frequent targets for hackers
- Large databases require significant hardware storage and processing power
Section 8: Safety and Ethical Considerations
Managing a database comes with serious responsibilities. Every student and professional working with data must understand the following:
Data Privacy Personal information stored in a database — names, phone numbers, health records, financial details — must be kept strictly confidential. Sharing or misusing someone's data without their permission is both unethical and illegal. Nigeria's Data Protection Regulation (NDPR) exists specifically to protect citizens from this kind of violation.
Access Control Not every user should be able to edit, delete, or even view all records. Database administrators must assign the right level of access to each person using DCL commands like GRANT and REVOKE.
Regular Backups Always back up your database regularly. This protects against data loss caused by power failures, hardware damage, or cyberattacks — all of which are real risks in the Nigerian environment.
Avoiding SQL Injection SQL injection is a hacking method where an attacker enters malicious commands into an input field — such as a login form — to gain unauthorised access to a database. Developers must always validate user inputs before they reach the database to prevent this.
Data Accuracy Entering wrong information carelessly — or deliberately falsifying records — can cause serious harm, especially in medical, financial, or examination systems. Accuracy is both a professional duty and an ethical responsibility.
Section 9: Classroom and Home Activities
Activity 1 — Create a School Database Using Microsoft Access or any available DBMS on your school computer, create a database called SchoolDB. Inside it, create a table called Results with the following fields: StudentName, Subject, Score, and Grade. Enter at least ten records and practise retrieving them using SELECT queries with different WHERE conditions.
Activity 2 — SQL Practice on Paper Without using a computer, write the SQL statements needed to: (a) select all students who scored more than 60, (b) update a student's score from 55 to 70 where StudentID equals 3, and (c) delete the record where StudentID equals 7. Have your teacher review your syntax before you run the queries on a computer.
Activity 3 — Generate a Report From the database you created in Activity 1, use the Report Wizard in Microsoft Access — or write a SELECT query with GROUP BY — to generate a summary showing the average score per subject. Print or present your report to the class and explain what the numbers mean.
Activity 4 — Ethics Discussion In groups of four, discuss this question: "Should a school secretary have the ability to edit student examination scores in the database? Why or why not?" Each group should present their position and reasoning to the rest of the class. Consider what safeguards should be put in place.
Section 10: Assessment Questions
Part A — Objective Questions (Circle the correct answer)
-
Which SQL command is used to retrieve data from a database table?
- A. INSERT
- B. UPDATE
- C. SELECT
- D. DELETE (Correct answer: C)
-
What does the WHERE clause do in an SQL query?
- A. Sorts the results alphabetically
- B. Filters records based on a specified condition
- C. Deletes all matching records
- D. Creates a new table in the database (Correct answer: B)
-
Which category of SQL commands includes CREATE, ALTER, and DROP?
- A. DML
- B. DQL
- C. DCL
- D. DDL (Correct answer: D)
-
Which SQL aggregate function returns the highest value in a column?
- A. SUM()
- B. MAX()
- C. COUNT()
- D. AVG() (Correct answer: B)
-
Which statement correctly removes records where Score is less than 40?
- A. REMOVE FROM Students WHERE Score < 40
- B. DELETE Students WHERE Score < 40
- C. DELETE FROM Students WHERE Score < 40
- D. DROP FROM Students WHERE Score < 40 (Correct answer: C)
Part B — Theory Questions (Answer in full sentences)
-
Explain what SQL is and list the four main categories of SQL commands. Give one example of a command from each category.
-
A secondary school in Kano wants to generate a report showing all JSS 3 students who scored 50 and above in their end-of-year examinations, arranged from the highest score to the lowest. Write the SQL query that would produce this report. Assume the table is called ExamResults and contains the columns: StudentName, Class, and Score.
-
State three ethical responsibilities of a database administrator working in a Nigerian hospital and explain why each one is important to patients and staff.
Summary
- A database is an organised collection of related data; a DBMS is the software used to create and manage it.
- SQL (Structured Query Language) is the standard language for communicating with relational databases.
- SQL commands fall into four categories: DDL (structure), DML (data changes), DQL (data retrieval), and DCL (access control).
- The most common SQL commands are CREATE, INSERT, SELECT, UPDATE, and DELETE.
- Clauses like WHERE, ORDER BY, and GROUP BY allow you to filter, sort, and group query results precisely.
- Aggregate functions — COUNT, SUM, AVG, MAX, MIN — perform calculations across multiple rows of data.
- Database reports present retrieved data in a structured and readable format to support decision-making.
- Responsible database use includes protecting data privacy, assigning proper access levels, backing up data regularly, and maintaining accuracy at all times.
Conclusion
Advanced database management is one of the most practical and valuable skills you can acquire in secondary school. The ability to organise, retrieve, and report on data using SQL is something that almost every industry in Nigeria depends on — education, banking, healthcare, government, retail, and logistics alike.
More than the technical skill, managing data responsibly — with honesty, accuracy, and respect for people's privacy — reflects the kind of professional character that Nigeria's growing digital economy truly needs.
As you continue to practise SQL and work with databases, carry this with you: data is powerful, and the way you handle it has real consequences for real people.
Frequently Asked Questions (FAQ)
Q1. What is the difference between a database and a DBMS? A database is the actual organised collection of data — like a library full of records. A DBMS is the software used to create, manage, and interact with that data — like the librarian and the cataloguing system together. Examples of DBMS include Microsoft Access, MySQL, Oracle, and SQLite.
Q2. Is SQL difficult to learn for SSS 3 students? Not at all. SQL is widely considered one of the easiest technical languages to learn because its syntax reads almost like plain English. A command such as SELECT name FROM students WHERE score > 50 is fairly self-explanatory. With regular practice, most SSS 3 students become comfortable with SQL within a few weeks.
Q3. What DBMS software should Nigerian students use for practice? Microsoft Access is widely available in Nigerian schools and is a great starting point. DB Browser for SQLite is free, lightweight, and runs on most computers without complex installation. MySQL is the professional standard and is also available for free download. All three allow you to write and run real SQL commands and build actual databases.
Q4. What is SQL injection and why is it dangerous? SQL injection is a cyberattack where a hacker types malicious commands into an input field — such as a website login form — to gain unauthorised access to a database. It is dangerous because it can expose sensitive personal, financial, or medical records. Developers prevent it by always checking and cleaning user inputs before they reach the database.
Q5. How are database reports different from spreadsheet reports? Spreadsheet reports, such as those made in Microsoft Excel, are usually built manually and work best for small data sets. Database reports are generated automatically from live data stored in a DBMS. They can handle millions of records, apply complex filters, and update automatically — something a spreadsheet cannot do at scale.
Q6. Will learning SQL help me find work in Nigeria? Absolutely. SQL is consistently ranked among the top five most in-demand technical skills both in Nigeria and globally. Banks, telecoms companies, government agencies, hospitals, e-commerce platforms, and tech startups all rely on database systems daily. Knowing SQL can open up career opportunities in data analysis, software development, IT administration, and business intelligence — all of which are fast-growing fields in Nigeria.
Subject: Digital Technologies | ICT | Computer Studies | Class: SSS 3 | Curriculum: NERDC | Content is original and produced for educational purposes.

0 Comments