SQL for SSS 2: What Is Structured Query Language, Its Categories, Syntax, and Why Every App Needs It.

SQL for SSS 2: What Is Structured Query Language, Its Categories, Syntax, and Why Every App Needs It


INTRODUCTION

Every time you log into your school portal, check your bank balance on a mobile app, or search for a product on Jumia, something powerful is happening behind the scenes. A language called SQL — Structured Query Language — is quietly doing the heavy lifting, fetching your data, sorting it, and delivering exactly what you need in milliseconds.

For Nigerian students in SSS 2, understanding SQL is not just a curriculum requirement — it is a doorway into the world of software development, data management, and digital entrepreneurship. As Nigeria's tech industry continues to grow, with hubs like Yaba Tech City in Lagos and rising startups across Abuja and Port Harcourt, the ability to work with databases using SQL is becoming one of the most valuable skills a young Nigerian can have.

In this lesson, you will learn what SQL is, the major categories it is divided into, how to write basic SQL queries with correct syntax, and why SQL is absolutely essential in building modern applications. Whether you want to become a software developer, a data analyst, or just want to understand how the digital world works, this topic is for you.

LEARNING OBJECTIVES

By the end of this lesson, students should be able to:

1. Define Structured Query Language (SQL) and explain its purpose in database management.

2. Identify and describe the four major categories of SQL commands.

3. Write basic SQL queries using correct syntax.

4. Give examples of SQL statements and explain what each one does.

5. Explain why SQL is important in the development of modern applications.

6. Relate the use of SQL to real-life situations in Nigeria and beyond.

WHAT IS SQL?

SQL stands for Structured Query Language. It is a standard programming language specifically designed for managing and manipulating data stored in a Relational Database Management System (RDBMS). In simpler terms, SQL is the language you use to communicate with a database — to store data, retrieve it, update it, or delete it.

Think of a database as a very large, well-organized filing cabinet. SQL is the instruction you give to that filing cabinet: "Find me the file for Chukwuemeka in Class SS2B," or "Add a new file for Ngozi who just enrolled," or "Delete the file for a student who graduated."

SQL was developed in the early 1970s at IBM by Donald D. Chamberlin and Raymond F. Boyce. Today, it is used in virtually every software application that stores data — from banking apps to hospital records, school management systems to e-commerce platforms.

Key terms you should know:

- Database: An organized collection of data stored electronically.

- Table: Data in a database is stored in tables, which look like spreadsheets with rows and columns.

- Query: A request or instruction you send to a database.

- Record/Row: A single entry in a table (e.g., one student's details).

- Field/Column: A category of data in a table (e.g., Name, Age, Class).

CATEGORIES OF SQL

SQL commands are grouped into four main categories based on what they do. These categories are DDL, DML, DCL, and TCL.

 1. DDL — Data Definition Language

DDL commands are used to define and manage the structure of a database. They deal with creating, modifying, or deleting database objects like tables.

Common DDL commands:

- CREATE: Used to create a new table or database.

- ALTER: Used to modify an existing table (e.g., add a new column).

- DROP: Used to delete an entire table or database.

- TRUNCATE: Used to remove all records from a table without deleting the table itself.

Example:

CREATE TABLE Students (

  StudentID INT,

  FirstName VARCHAR(50),

  LastName VARCHAR(50),

  Class VARCHAR(10),

  Age INT

);

This SQL statement creates a table called Students with five columns: StudentID, FirstName, LastName, Class, and Age. Imagine your school administrator setting up a new register for all students — this is exactly what CREATE TABLE does in a database.

2. DML — Data Manipulation Language

DML commands are used to manage data within the tables. These are the most commonly used SQL commands because they handle the day-to-day reading, adding, changing, and removing of data.

Common DML commands:

- SELECT: Retrieves data from a table.

- INSERT: Adds new records into a table.

- UPDATE: Modifies existing records.

- DELETE: Removes specific records from a table.

Examples:

INSERT INTO Students (StudentID, FirstName, LastName, Class, Age)

VALUES (1, 'Tunde', 'Adeyemi', 'SS2A', 17);

This adds a new student named Tunde Adeyemi to the Students table.

SELECT FirstName, LastName, Class

FROM Students

WHERE Age = 17;

This retrieves the first name, last name, and class of every student who is 17 years old.

UPDATE Students

SET Class = 'SS3A'

WHERE StudentID = 1;

This changes Tunde's class from SS2A to SS3A (perhaps at the start of a new academic session).

DELETE FROM Students

WHERE StudentID = 1;

This removes Tunde's record from the table entirely — for example, if he has transferred to another school.

3. DCL — Data Control Language

DCL commands are used to control access to data in a database. They manage permissions — deciding who can view, edit, or manage certain data.

Common DCL commands:

- GRANT: Gives a user permission to perform certain actions on a database.

- REVOKE: Takes away previously granted permissions.

Example:

GRANT SELECT ON Students TO 'teacher_ada';

This gives a teacher named Ada permission to view (but not edit) the Students table.

REVOKE SELECT ON Students FROM 'teacher_ada';

This takes away Ada's viewing permission.

DCL is very important in real-world systems. For example, in a hospital database, a nurse might have permission to view patient records but not to delete them. A doctor might have permission to update records. The hospital administrator would manage all these using DCL.

4. TCL — Transaction Control Language

TCL commands are used to manage transactions in a database. A transaction is a group of SQL operations that should all succeed together or all fail together — none of them should be left half-done.

Common TCL commands:

- COMMIT: Saves all the changes made in a transaction permanently.

- ROLLBACK: Undoes changes made in the current transaction, going back to the last saved state.

- SAVEPOINT: Sets a temporary save point within a transaction so you can roll back to it if needed.

Example:

Think of a bank transfer. If Emeka wants to send ₦5,000 to Fatima:

- Step 1: Deduct ₦5,000 from Emeka's account.

- Step 2: Add ₦5,000 to Fatima's account.

If Step 1 succeeds but Step 2 fails (due to a network error), the ₦5,000 should not just disappear. TCL ensures that either both steps happen (COMMIT) or neither does (ROLLBACK). This is critical for the safety of financial applications like those used by Nigerian banks.

SQL SYNTAX: THE RULES FOR WRITING SQL

Just like every language has grammar rules, SQL has syntax — a specific way commands must be written for the database to understand them.

Basic SQL Syntax Rules:

1. SQL keywords are usually written in UPPERCASE (e.g., SELECT, FROM, WHERE), though lowercase also works. Using uppercase is a widely accepted best practice.

2. Every SQL statement should end with a semicolon (;).

3. Text values (strings) are placed inside single quotation marks (e.g., 'Tunde').

4. Column names and table names are usually written without quotation marks.

5. SQL is not case-sensitive for keywords, but it may be case-sensitive for data values depending on the database system.

General Syntax of the SELECT Statement:


SELECT column1, column2

FROM table_name

WHERE condition

ORDER BY column1 ASC/DESC;


- SELECT tells the database which columns you want.

- FROM tells it which table to look in.

- WHERE filters the results based on a condition.

- ORDER BY sorts the results (ASC means ascending, DESC means descending).

Full Working Example Using a Nigerian Context:

Imagine a school database with a table called Exam_Results containing columns: StudentName, Subject, Score, and Grade.

SELECT StudentName, Score, Grade

FROM Exam_Results

WHERE Subject = 'Computer Studies'

ORDER BY Score DESC;

This query will return the names, scores, and grades of all students who took Computer Studies, sorted from the highest score to the lowest. A school administrator or teacher could run this query to quickly identify the top-performing students.

THE NEED FOR SQL IN APP DEVELOPMENT

Every modern application — whether it is a simple school result checker or a complex banking platform — needs a place to store and retrieve data. That place is a database. And the tool used to interact with that database is almost always SQL.

Here is why SQL is so important in app development:

1. It Powers Data Storage and Retrieval

Every time a user of an app like Flutterwave, Paystack, or even a school management portal registers, logs in, or makes a transaction, their data is stored in a database. SQL is what the app uses to save that information and retrieve it when needed.

2. It Handles Large Volumes of Data Efficiently

SQL databases can handle millions of records with ease. A university like the University of Lagos or Ahmadu Bello University has thousands of students, courses, lecturers, and results. SQL makes it possible to store and search all of this data quickly and accurately.

 3. It Ensures Data Accuracy and Consistency

SQL uses rules (called constraints) to make sure data entered into a database is correct and consistent. For example, it can enforce that no two students have the same ID number, or that a student's age cannot be a negative number.

 4. It Supports Multiple Users Simultaneously

In a real app, many users are interacting with the database at the same time. SQL databases are built to handle this without confusion or data loss, which is critical for apps like GTBank's mobile banking platform or WAEC's result portal.

5. It Works Across Many Platforms and Languages

SQL is supported by virtually all major database systems — MySQL, PostgreSQL, Microsoft SQL Server, SQLite, and Oracle. It also integrates seamlessly with programming languages like Python, PHP, Java, and JavaScript. This means that no matter what language a Nigerian developer uses to build an app, SQL is always available as the database layer.

PRACTICAL APPLICATIONS IN NIGERIA

SQL is not just a classroom topic — it is being used every day in Nigerian institutions and businesses:

- School Management Systems: Schools like those under SUBEB and UBEC use database-driven platforms to manage student enrolment, results, and attendance. SQL powers these systems.

- Healthcare: Government hospitals and private clinics use database systems to store patient records. SQL helps doctors and nurses retrieve patient history quickly.

- Banking and Fintech: Nigerian banks like Access Bank, Zenith Bank, and fintech startups like Opay and Kuda Bank rely heavily on SQL databases to manage millions of customer transactions daily.

- E-Commerce: Online stores on Jumia and Konga store product listings, customer information, and order histories using SQL databases.

- Government Records: Agencies like INEC (Independent National Electoral Commission) and NIMC (National Identity Management Commission) use SQL to manage national databases.

ADVANTAGES OF SQL

- Easy to learn and use, even for beginners.

- Works with almost all database management systems.

- Can handle and process large amounts of data.

- Allows multiple users to access data at the same time.

- Provides strong data security through DCL commands.

- Widely used, meaning there are many jobs and career opportunities for people who know SQL.

DISADVANTAGES OF SQL

- Complex queries can be difficult to write and debug for beginners.

- Not ideal for unstructured data like videos, images, or social media posts (for those, NoSQL databases are used).

- Some advanced SQL features differ between database systems, which can cause compatibility issues.

- Poor database design can lead to slow performance even with correct SQL.

ETHICAL AND SAFETY CONSIDERATIONS

As powerful as SQL is, it can be misused. Here are some important points for responsible use:

- Do not use SQL to access databases you do not have permission to access. Unauthorized access to a database is illegal and a violation of people's privacy.

- Never store sensitive personal data (like passwords) in plain text. Good developers always encrypt sensitive data.

- Always back up your database regularly to prevent loss of important data.

- Be careful with DELETE and DROP commands — once data is deleted and committed, it may be impossible to recover.

- In professional settings, always follow your organization's data protection policies. In Nigeria, the Nigeria Data Protection Regulation (NDPR) governs how personal data should be stored and handled.

CLASSROOM AND HOME ACTIVITIES

Activity 1 — Create a Simple Table:

On paper or using any SQL tool available to you, write the SQL statement to create a table called Library_Books with the following columns: BookID, Title, Author, Year_Published, and Copies_Available.

Activity 2 — Write a Query:

Using the Exam_Results table mentioned earlier (columns: StudentName, Subject, Score, Grade), write SQL statements to:

a) Add a new result record for a student named Adaeze Okafor who scored 85 in Mathematics with a Grade A.

b) Retrieve all students who scored above 70 in any subject.

Activity 3 — Identify the Category:

Look at the following SQL commands and identify which category each one belongs to (DDL, DML, DCL, or TCL):

a) CREATE TABLE

b) SELECT

c) GRANT

d) ROLLBACK

e) DELETE

f) ALTER

Activity 4 — Real-Life Scenario:

Imagine you are building a simple student attendance app for your school. Write down at least three tables you would need in your database and list the columns each table would contain. Then write one SELECT query to retrieve attendance records for a specific student.

ASSESSMENT QUESTIONS

SECTION A — Objective Questions

1. What does SQL stand for?

a) Sequential Query Language

b) Structured Query Language

c) Simple Query Language

d) System Query Language

2. Which category of SQL is used to control access and permissions in a database?

a) DDL

b) DML

c) DCL

d) TCL

3. Which SQL command is used to retrieve data from a table?

a) INSERT

b) UPDATE

c) DELETE

d) SELECT

4. The ROLLBACK command belongs to which category of SQL?

a) DDL

b) DML

c) TCL

d) DCL

5. Which SQL command would you use to permanently remove a table from a database?

a) DELETE

b) REMOVE

c) DROP

d) TRUNCATE

SECTION B — Theory Questions

1. Explain the four categories of SQL commands. Give one example of a command from each category and describe what it does.

2. Write the SQL query to create a table named Customers with the following columns: CustomerID (integer), FullName (text, maximum 100 characters), PhoneNumber (text, maximum 15 characters), and City (text, maximum 50 characters). Then write a query to insert one record into the table using Nigerian names and a Nigerian city of your choice.

3. Why is SQL important in modern app development? Use at least two examples from Nigerian digital platforms to support your answer.

SUMMARY

In this lesson, you have learned that:

- SQL (Structured Query Language) is the standard language used to interact with relational databases.

- SQL commands are grouped into four categories: DDL (Data Definition Language) for defining database structure, DML (Data Manipulation Language) for managing data, DCL (Data Control Language) for controlling access, and TCL (Transaction Control Language) for managing transactions.

- SQL has a specific syntax that must be followed when writing queries, including the use of keywords like SELECT, FROM, WHERE, INSERT, UPDATE, and DELETE.

- SQL is absolutely essential in modern app development because it powers data storage, retrieval, accuracy, and multi-user access.

- Real-life Nigerian platforms — from banks to schools to e-commerce sites — all rely on SQL databases.

- Responsible and ethical use of SQL includes respecting data privacy laws like Nigeria's NDPR and being cautious with irreversible commands.

CONCLUSION


SQL is one of those skills that quietly powers the entire digital economy. Behind every Nigerian banking app, school portal, and online marketplace is a database — and behind that database is SQL. As an SSS 2 student, understanding SQL puts you ahead of the curve in a country that is rapidly becoming a major player in Africa's digital landscape.


The knowledge of SQL is not just for university students or professional programmers. It starts right here, in your secondary school classroom, with the basics you have learned today. As you continue to practice and explore, you will discover that SQL is not as intimidating as it looks — it is logical, structured, and surprisingly rewarding when you see your queries return exactly the data you asked for.


Keep practicing. Keep building. Nigeria's tech future is being written by young people exactly like you.


FREQUENTLY ASKED QUESTIONS (FAQ)


Q1: What is SQL in simple terms?

SQL is a language used to talk to databases. Just as you use English to communicate with people, you use SQL to communicate with a database — asking it to store, find, update, or delete information.


Q2: Is SQL a programming language?

SQL is technically a query language rather than a general-purpose programming language like Python or Java. However, it is considered a form of programming because you write instructions that a computer system must execute. It is often used alongside general-purpose programming languages in app development.


Q3: What is the difference between DDL and DML?

DDL (Data Definition Language) deals with the structure of a database — creating and modifying tables. DML (Data Manipulation Language) deals with the actual data inside those tables — inserting, reading, updating, and deleting records.


Q4: Which SQL database system is most commonly used?

MySQL is one of the most widely used SQL database systems in the world, especially for web applications. PostgreSQL and SQLite are also very popular. Microsoft SQL Server is commonly used in corporate environments.


Q5: Do Nigerian companies use SQL?

Absolutely. Almost every technology-driven company in Nigeria — including banks, telecoms, hospitals, universities, and e-commerce platforms — uses SQL-based databases to manage their data.


Q6: Can I learn SQL as an SSS 2 student with no prior coding experience?

Yes, you can. SQL is one of the most beginner-friendly database languages. The basic commands like SELECT, INSERT, UPDATE, and DELETE are easy to understand and practice, even without prior coding knowledge. Starting early, as you are doing now, gives you a great advantage.

Post a Comment

0 Comments