By the end of this chapter, you will be able to:
Mastering this skill helps ensure that database systems work correctly and meet users' needs, making you a valuable asset in the tech field.
Compiled by: Ann Chebet
Test computerized database systems are essential for ICT Technicians in Kenya who maintain and develop reliable data management solutions across industries such as banking, healthcare, and government services. Rigorous testing ensures databases perform accurately, securely, and efficiently to support critical operations like customer transactions, patient records, and financial reporting. This chapter focuses on developing effective test plans and preparing appropriate test data to validate database systems, which are foundational skills for ICT Technicians tasked with deploying and maintaining computerized databases.
A database test plan is the document that says what will be tested in a database, how, by whom, when, with what data and what result counts as a pass. It is written before testing starts so that the work is systematic and every important feature is covered. Without a plan, testers check only what comes to mind first and leave gaps. The examples in this topic use a small internet service provider (ISP) billing database with three tables: packages, subscribers and payments.
packages
package_id package_name monthly_fee_ksh
P1 Home Basic 2000
P2 Home Plus 3500
P3 Business 6000
subscribers
subscriber_id full_name package_id status
7001 Anne Njeri P1 Suspended
7002 Omar Salim P2 Suspended
7003 Grace Wafula P3 Active
payments
payment_id subscriber_id amount_ksh paid_on
8001 7003 6000 2026-11-01
A test plan is made of a fixed set of parts. Each part answers one question that the testers and the people approving the plan need answered.
A test plan is developed in a sequence of steps, so that nothing is missed and every test can be traced to a requirement.
Database testing checks that the data a system stores is correct, safe and available when it is needed. The database sits underneath every screen and report, so a fault here spreads to everything above it. A technician who tests the database properly protects the trust that managers and customers place in the system.
Testing verifies that stored data stays correct and consistent after inserts, updates and deletions. For example, after a payment of Ksh 2,000 is recorded for subscriber 7001, the payments table must hold exactly one new row with the right amount, and the subscriber's status must change correctly. A fault found now is cheaper to correct than wrong invoices discovered at month end.
Testing exposes weaknesses that could reveal or damage sensitive data, such as weak access rights or an input field that accepts malicious SQL. Subscriber names and phone numbers are personal data, and the Data Protection Act, 2019 expects organisations that hold such data to protect it. Testing that each user can reach only the data allowed to that role supports that duty.
Performance testing shows whether queries and transactions finish in an acceptable time, including when many users work at once. A billing database that answers in a fraction of a second with ten test records may become very slow when it holds many thousands of payments, and the slowness is found by testing and not by guessing.
Testing finds mistakes in the design itself, such as a missing relationship between tables, a field with the wrong data type or a constraint that was never created. If subscribers could be saved with a package that does not exist, invoices would be wrong without any visible error message.
Regular, recorded testing shows that the system follows the rules it was built for, such as an organisation's own data policy or the terms in a service agreement with a customer. The test records become evidence that the rules were checked and not only assumed.
Database testing is divided into types because each type looks at a different side of the database. Some check the structure, some check what the database does, and some check how well it does it. A test plan normally combines several of them.
| Type | What it checks | Example from the ISP billing database |
|---|---|---|
| Structural DB testing | Tables, columns, keys and other objects | The payments table has an amount field that rejects negative numbers |
| Functional testing | That operations give the correct business result | A payment that covers the fee changes the status to Active |
| Stored procedure testing | The routines saved inside the database | The record_payment routine stores a payment and updates the status |
| Non-functional testing | Speed, capacity and behaviour under pressure | Many subscribers paying at the same time on the last day of the month |
Structural testing checks the objects that make up the database and the rules attached to them, without looking at what the application does with them. It confirms that the database was built as designed. Testers compare the database with the design documents, and they often read the structure with queries on the system tables and on the information schema, so that the checking can be repeated.
A schema is the organised collection of the tables, views, indexes, keys and other objects of a database, with their definitions. Schema testing confirms that the objects named in the design exist, that they are named correctly and that the relationships between them are in place. Example: after the billing database is installed on a test server, the tester lists the tables and compares the list with the design.
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'isp_billing';
The expected result is three rows: packages, payments and subscribers. In MySQL the table_schema value is the database name, while in PostgreSQL it is the schema name, often public. A fourth, unplanned table would show that the installation differs from the design.
Table and column testing checks the detail inside each table: the data type, size, default value, whether the field may be empty, and the keys and constraints on each column. The tester reads the definition and then tries to break the rules with wrong values. The column definitions can be listed with a query and compared with the design.
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'payments';
The next table shows structural test cases for the billing database.
| Test | Action | Expected result |
|---|---|---|
| Duplicate key | Insert a payment with payment_id 8001 again | Rejected, because the primary key must be unique |
| Required field | Insert a subscriber with no full_name | Rejected, because the column does not accept empty values |
| Broken link | Insert a subscriber with package_id P9 | Rejected, because package P9 does not exist |
| Value range | Insert a payment with amount_ksh of -500 | Rejected by the check rule, because an amount cannot be negative |
| Field size | Insert a name longer than the column length | Rejected in strict mode, and a defect if it is silently cut short |
Functional testing checks that the operations of the database give the correct result according to the business rules. It tests what the database does: inserting, reading, updating and deleting data, running queries, and applying rules through constraints, triggers and views. Example: in the billing database, the rule is that a subscriber becomes Active when the payments in the month reach the monthly fee of the package.
Whitebox testing is carried out with knowledge of the internal structure and code of the database. The tester reads the table definitions, triggers, views and stored routines, and designs tests that exercise every part of them. It is usually done by the developer or a technician with access to the database code. Example: a trigger writes a row to an audit table whenever a payment is changed. The tester updates payment 8001 and checks that the audit table holds the old and the new amount.
Blackbox testing treats the database as a closed box: the tester supplies inputs through a form, a screen or a query and checks the outputs, without looking at the code or the structure inside. It is done by testers and by users, because it shows what a user would experience. Common techniques are equivalence partitioning, boundary value analysis and error guessing. Example: assume the billing rules accept a payment of Ksh 1 to Ksh 100,000. Input values are grouped into three partitions, below the range, inside it and above it, and the edges of the range are tested.
| Input amount (Ksh) | Partition | Expected result |
|---|---|---|
| 0 | Below the range | Rejected |
| 1 | Lowest valid value | Accepted |
| 100000 | Highest valid value | Accepted |
| 100001 | Above the range | Rejected |
A stored procedure is a set of SQL statements saved inside the database and run by name, usually with input values called parameters. Applications use procedures to carry out important tasks in a consistent way. Stored procedure testing checks that each procedure returns the right results, handles wrong input safely and leaves the data consistent. Example: the procedure record_payment takes a subscriber number and an amount, stores the payment and sets the status to Active when the month's payments reach the package fee. It is called with CALL record_payment(7001, 2000); in MySQL and PostgreSQL, while SQL Server uses EXEC.
| Case | Input | Expected result |
|---|---|---|
| Full payment | Subscriber 7001, amount 2000 | One payment row stored, status becomes Active |
| Part payment | Subscriber 7002, amount 1500 | Row stored, status stays Suspended, Ksh 2,000 still unpaid (3500 - 1500) |
| Completing payment | Subscriber 7002, amount 2000 | Row stored, payments total 3500, status becomes Active |
| Unknown subscriber | Subscriber 9999, amount 1000 | Error message, no row stored |
| Invalid amount | Subscriber 7001, amount 0 or a negative value | Error message, no row stored |
| Missing value | Subscriber 7001, amount empty (NULL) | Error message, no row stored |
Non-functional testing checks how well the database performs its work, rather than what work it does. The questions are about speed, capacity, safety and recovery. A payment screen that gives the correct answer after two minutes passes a functional test but fails a non-functional one. Besides load and stress testing, non-functional testing also covers the following.
Load testing measures how the database behaves under the amount of work it is expected to carry, including the busiest period. The test simulates many users or many transactions at the same time and records the response time, the number of transactions completed per second and the use of processor, memory and disk. Example: on the last day of the month many ISP subscribers pay at once. The plan sets the normal load and the expected peak, and states a target, for example that 95 percent of payments are recorded in under 2 seconds.
Tools for generating the load include Apache JMeter, pgbench for PostgreSQL and mysqlslap for MySQL. The tool should be matched to the database system and its version.
Stress testing pushes the database beyond its expected limits, until it slows badly or fails, to find the breaking point and to see how it fails and recovers. Where load testing asks whether the system copes with the expected peak, stress testing asks what happens when the peak is exceeded. Example: after the 200-user step in the billing test, the load is raised in further steps until payments begin to time out.
The difference between the two tests is summarised below.
| Point | Load testing | Stress testing |
|---|---|---|
| Aim | Prove that the expected load is handled | Find the limit and the way the system fails |
| Load level | Normal and expected peak | Beyond the expected peak |
| Result looked for | Response times within the targets | Breaking point and recovery behaviour |
Explain five reasons why database testing is important for ICT Technicians working in Kenyan public service institutions. (10 marks)
Describe four types of database testing and provide an example use case for each within the Kenyan financial sector. (12 marks)
Outline six essential components of a database test plan and explain their significance in managing testing activities. (12 marks)
List and explain the seven steps involved in developing a database test plan for a university student information system. (14 marks)
Create a free account to open more of this chapter.
Free: practical guides, quick cards, workplace scenarios and more.
Create a free accountThis chapter focused on the systematic process of testing computerized database systems, beginning with the development of a comprehensive test plan that outlines the scope and objectives of database testing. The importance of database testing was emphasized as a crucial step to ensure data integrity, performance, and security. Various types of database testing were explored, including structural testing which examines the database schema, functional testing that verifies database operations, stored procedure testing to validate embedded logic, and non-functional testing addressing performance and scalability. The preparation of test data was highlighted as essential for simulating real-world scenarios and ensuring thorough evaluation. The chapter then covered how to perform database testing using the prepared test data, including the critical task of validating database results to confirm accuracy and reliability. Finally, the generation of test reports was discussed, underscoring their role in documenting findings and supporting decision-making, along with guidelines on how to prepare clear and informative test reports.
Type: Individual
| Tools & Equipment | Materials |
|---|---|
| Computer with database testing software installed | Test plan template document |
| Test plan template document | Sample database schema documentation |
| Sample database schema documentation | Test case checklist |
| Test case checklist |
| S/N | Item | Quantity |
|---|---|---|
| 1 | Computer with database testing software installed | 1 Pc per Candidate |
| 2 | Test plan template document | 1 Pc per Candidate |
| 3 | Sample database schema documentation | 1 Pc per Candidate |
| 4 | Test case checklist | 1 Pc per Candidate |
| Items to be Evaluated | Marks Available | Marks Obtained | Comments |
|---|---|---|---|
| TASK 1: Test Plan Development | |||
| Identified and stated clear test objectives (Award 5 marks for clear, measurable test objectives) | 5 | ||
| Defined the scope of testing including inclusions and exclusions (Award 5 marks for comprehensive and relevant scope definition) | 5 | ||
| Developed detailed test cases covering functional and non-functional requirements (Award up to 10 marks for completeness and relevance of test cases) | 10 | ||
| Specified required resources including hardware, software, and personnel (Award 5 marks for correctly identifying all necessary resources) | 5 | ||
| Prepared a realistic testing schedule with milestones and deadlines (Award 5 marks for a clear, feasible schedule) | 5 | ||
| Saved and formatted the test plan document professionally (Award 5 marks for proper document formatting and saving) | 5 | ||
| Sub-Total | 35 | ||
| PRODUCT CHECKLIST | |||
| Test plan document completeness and clarity (Award 10 marks for a well-structured, error-free, and comprehensive test plan) | 10 | ||
| Sub-Total | 10 | ||
| GRAND TOTAL | 45 | ||
Type: Individual
| Tools & Equipment | Materials |
|---|---|
| Desktop Computer with Database Management System (DBMS) software | Test Data Set (customer records) |
| USB Flash Drive |
| S/N | Item | Quantity |
|---|---|---|
| 1 | Desktop Computer with Database Management System (DBMS) software | 1 Pc per Candidate |
| 2 | Test Data Set (customer records) | 1 Set per Candidate |
| 3 | USB Flash Drive | 1 Pc per Candidate |
| Items to be Evaluated | Marks Available | Marks Obtained | Comments |
|---|---|---|---|
| TASK 1: Database Creation and Setup | |||
| Launched DBMS software and created a new database named 'CustomerDB' (Award 1 mark for launching and naming database correctly) | 1 | ||
| Created two tables: Customers and Orders with appropriate field names (Award 0.5 mark for each correct field name per table) | 6 | ||
| Assigned correct data types to each field in both tables (Award 0.5 mark per field for correct data type) | 6 | ||
| Defined primary key constraints on appropriate fields (Award 1 mark per table for correct primary key) | 2 | ||
| Defined foreign key constraint in Orders table referencing Customers table (Award 2 marks for correct foreign key constraint) | 2 | ||
| Sub-Total | 17 | ||
| TASK 2: Data Population and Testing | |||
| Populated Customers and Orders tables with provided test data (minimum 10 records total) (Award 1 mark per 5 correctly entered records) | 6 | ||
| Created query to display all customers with their orders (Award 3 marks for correct join query) | 3 | ||
| Created query to list customers from Nairobi only (Award 3 marks for correct filtering query) | 3 | ||
| Created query to display orders above Ksh 10,000 (Award 3 marks for correct conditional query) | 3 | ||
| Tested constraints by attempting to insert invalid data and prevented insertion (Award 4 marks for demonstrating constraint enforcement) | 4 | ||
| Sub-Total | 19 | ||
| TASK 3: Database Export and Documentation | |||
| Exported the database file and saved it on the USB flash drive (Award 3 marks for successful export and correct file naming) | 3 | ||
| Prepared a brief report summarizing the importance of database testing (Award 2 marks for each valid point on data integrity, error detection, and performance) | 6 | ||
| Sub-Total | 9 | ||
| PRODUCT CHECKLIST | |||
| Database contains two correctly structured tables with accurate fields and constraints (Award 6 marks for complete and accurate table design) | 6 | ||
| Queries run correctly and return expected results (Award 6 marks for correct query outputs) | 6 | ||
| Database exported correctly and report is clear and concise (Award 4 marks for proper export and meaningful report) | 4 | ||
| Sub-Total | 16 | ||
| GRAND TOTAL | 61 | ||
At the start of this chapter we promised you would be able to:
Tick each one you can genuinely do.
So, are you there yet?
You're competent when you can confidently do 50% or more of what this chapter promised.
Sign in to record how you're doing.