By the end of this chapter, you will be able to:
These skills will help you build reliable database systems while keeping your workplace safe and environmentally responsible—key qualities for success in the tech trade!
Creating a database system is a fundamental skill for software development professionals in Kenya, particularly as organizations increasingly rely on data-driven decision-making. Effective database creation enables efficient data storage, retrieval, and management, forming the backbone of many software applications in sectors such as banking, healthcare, education, and government. This chapter explores the essential components involved in building a database system, focusing on the creation of database objects and fields, which are critical to structuring data logically and functionally.
The creation of database objects is a core activity when setting up a database system. These objects define the structure and schema of the database, allowing software developers to organize data effectively. In Kenya’s dynamic software industry, understanding these objects is vital for building scalable and maintainable database solutions that meet client and regulatory requirements.
Database objects are the fundamental building blocks within a database system that store, organize, and manipulate data. They include tables, views, indexes, stored procedures, and triggers, each serving a specific purpose in managing data efficiently. Software developers working in Kenyan firms or on projects for institutions such as the Kenya Revenue Authority (KRA) rely on these objects to design robust databases that support complex data operations.
Tables are the primary objects where data is stored in rows and columns, similar to spreadsheets. Each row represents a record, while columns represent attributes or fields of the data. For example, a hospital management system might have tables for patients, doctors, and appointments. Tables must be carefully designed with appropriate data types and constraints to ensure data integrity and performance.
Views are virtual tables created by querying one or more tables. They provide a way to present data selectively without exposing the underlying tables directly. In banking software, for instance, views can restrict access to sensitive customer information while allowing staff to view relevant data subsets.
Indexes are database objects that improve the speed of data retrieval operations by creating pointers to data within tables. Proper indexing is crucial in large databases like those used by educational institutions managing thousands of student records. However, excessive indexing can slow down data insertion and updates, requiring balanced implementation.
Stored procedures are precompiled SQL code blocks stored in the database, allowing repetitive tasks or complex operations to be executed efficiently. Kenyan software developers often use stored procedures to enforce business rules or automate data processing in systems such as SACCO management platforms.
Triggers are special procedures that automatically execute in response to specific events on a table, such as insertions, deletions, or updates. They are useful for maintaining audit trails or enforcing complex integrity constraints without manual intervention, as seen in county government financial systems.
Fields, also known as columns or attributes, define the individual data elements stored within a table. Each field has a specific data type and constraints that determine what kind of data it can hold. Proper field definition is critical for data accuracy and consistency in software applications used in diverse Kenyan sectors.
Choosing the correct data type for a field ensures efficient storage and accurate data processing. Common data types include integers, decimals, characters, dates, and booleans. For example, a university database might use date fields to track student enrollment dates and decimal fields to store GPA values.
Constraints restrict the type of data that can be entered into a field, preventing invalid data entry. Typical constraints include NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK. In retail business databases, a UNIQUE constraint on product codes prevents duplicate entries, ensuring inventory accuracy.
Consistent and descriptive field naming enhances readability and maintainability of database schemas. Kenyan developers often follow conventions such as using lowercase letters, underscores to separate words, and meaningful names like "customer_id" or "transaction_date" to facilitate collaboration and future system upgrades.
Fields can have default values that are automatically assigned when no explicit value is provided during data entry. This feature simplifies data input and ensures essential fields have valid data. For instance, a hotel booking system might default the "booking_status" field to "pending" when a new reservation is created.
Fields that are frequently searched or used in join operations may require indexing to speed up query performance. However, indexing every field is inefficient, so developers must identify key fields that benefit the most from indexing, such as customer ID fields in SACCO databases.
Create a free account to open more of this chapter.
Free: practical guides, quick cards, workplace scenarios and more.
Create a free accountThis chapter explored the creation of database systems by first examining the various database objects essential for effective data management, including tables, forms, queries, reports, and macros. It then focused on the structure of data within these objects, highlighting the importance of fields, records, data types, field properties, and keys in organizing and securing information. The development process of a database was detailed through the steps of creating tables, establishing relationships between tables, and designing queries, forms, and reports to facilitate data manipulation and presentation. Additionally, the chapter addressed critical elements such as integrity constraints and database indexing to ensure data accuracy and optimize performance. Lastly, it described different types of data relationships, including one-to-one, one-to-many, many-to-one, and many-to-many, which define how data entities interact within a database system. Together, these topics provide a comprehensive foundation for constructing and managing computerized databases effectively.
Type: Individual
| Tools & Equipment | Materials |
|---|---|
| Relational Database Management System (MySQL, PostgreSQL, MS SQL Server) | Rewritable Compact Disc (CD-RW) |
| Data Modelling Tool (Lucidchart, EdrawMax, Draw.io) |
| S/N | Item | Quantity |
|---|---|---|
| 1 | Relational Database Management System (MySQL, PostgreSQL, MS SQL Server) | 1 Pc per Candidate |
| 2 | Data Modelling Tool (Lucidchart, EdrawMax, Draw.io) | 1 Pc per Candidate |
| 3 | Rewritable Compact Disc (CD-RW) | 1 Pc per Candidate |
| Items to be Evaluated | Marks Available | Marks Obtained | Comments |
|---|---|---|---|
| TASK 1: Create database and tables | |||
| Created database named 'StudentRegistration' (Award 1 mark for correct database creation) | 1 | ||
| Created table 'Students' with fields and appropriate data types (Award 1 mark for each correct field and data type: StudentID integer PK, FirstName varchar, LastName varchar, DateOfBirth date, Email varchar) | 4 | ||
| Created table 'Courses' with fields and appropriate data types (Award 1 mark for each correct field and data type: CourseID integer PK, CourseName varchar, DurationMonths integer) | 3 | ||
| Created table 'Enrollments' with fields and appropriate data types (Award 1 mark for each correct field and data type: EnrollmentID integer PK, StudentID integer FK, CourseID integer FK, EnrollmentDate date) | 4 | ||
| Set primary keys on StudentID, CourseID, EnrollmentID fields respectively (Award 1 mark for each primary key defined) | 3 | ||
| Set foreign key constraints on Enrollments.StudentID and Enrollments.CourseID referencing Students and Courses respectively (Award 1.5 marks for each foreign key constraint) | 3 | ||
| Used consistent naming conventions for tables and fields (Award 2 marks for consistent and meaningful naming) | 2 | ||
| Sub-Total | 20 | ||
| PRODUCT CHECKLIST | |||
| Students table with fields: StudentID (integer, PK), FirstName (varchar), LastName (varchar), DateOfBirth (date), Email (varchar) (Award 3 marks for correct fields, data types, and primary key) | 3 | ||
| Courses table with fields: CourseID (integer, PK), CourseName (varchar), DurationMonths (integer) (Award 2 marks for correct fields, data types, and primary key) | 2 | ||
| Enrollments table with fields: EnrollmentID (integer, PK), StudentID (integer, FK), CourseID (integer, FK), EnrollmentDate (date) (Award 3 marks for correct fields, data types, primary key, and foreign keys) | 3 | ||
| Referential integrity enforced via foreign keys between Enrollments and Students, and Enrollments and Courses (Award 2 marks for correct foreign key constraints) | 2 | ||
| Database structure follows normalization and best design practices (Award 2 marks for normalization and consistent naming) | 2 | ||
| Sub-Total | 12 | ||
| GRAND TOTAL | 32 | ||
Type: Individual
| Tools & Equipment | Materials |
|---|---|
| Relational Database Management System (MySQL, PostgreSQL, MS SQL Server etc.) | integer |
| Data Modelling Tool (Lucidchart, EdrawMax, Draw.io etc.) | varchar |
| Rewritable Compact Disc (CD-RW) | date/time |
| S/N | Item | Quantity |
|---|---|---|
| 1 | Relational Database Management System (MySQL, PostgreSQL, MS SQL Server etc.) | 1 Pc per Candidate |
| 2 | Data Modelling Tool (Lucidchart, EdrawMax, Draw.io etc.) | 1 Pc per Candidate |
| 3 | Rewritable Compact Disc (CD-RW) | 1 Pc per Candidate |
| Items to be Evaluated | Marks Available | Marks Obtained | Comments |
|---|---|---|---|
| TASK 1: Define Database Keys | |||
| Mapped entities from the ERD into six (6) relations (Award 1 mark per correctly mapped relation, zero if incorrect) | 3 | ||
| Specified attributes for the six (6) relations (Award 1 mark per table for correct attributes with data types) | 6 | ||
| Specified primary keys for the six (6) relations (Award 0.5 mark per correct primary key per table) | 3 | ||
| Specified composite primary keys for the marks and subject-teacher relations (Award 1 mark per correct composite primary key) | 2 | ||
| Enforced referential integrity by specifying foreign keys in the referencing relations (Award 1 mark per correctly defined foreign key with constraints) | 4 | ||
| Printed the relational schema (Award 1 mark for clear, complete printed schema) | 1 | ||
| Sub-Total | 19 | ||
| PRODUCT CHECKLIST | |||
| Created database and six (6) tables with required attributes and data types (Award 2 marks per table created with correct attributes and data types) | 12 | ||
| Enforced entity integrity (primary key) constraints in the six (6) tables (Award 1 mark per table for correct primary key enforcement) | 6 | ||
| Enforced referential integrity (foreign key) constraints in the six (6) tables (Award 1 mark per table for correct foreign key enforcement) | 6 | ||
| Utilized best practices in Database Design: (a) Well normalized relations (b) Consistent naming scheme for relations and attributes (Award 2 marks for normalization, 2 marks for consistent naming) | 4 | ||
| Sub-Total | 28 | ||
| GRAND TOTAL | 47 | ||
At the start of this chapter we promised you would be able to:
Tick each one you can genuinely do.
Sample simulation — try how the simulator works. A version built for this chapter's practical is coming.
Prepare Kenyan PilauLocked ▸Free: practical guides, quick cards, workplace scenarios and more.
Now — 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.