MGU Computer Science Series — CS Foundations
Part IV: Computer Systems
Tables · Keys · SQL · Transactions · Information Systems
Chapter 18 of 28
MGU Computer Science Series  ·  Computer Science Foundations  ·  Library Textbook Edition

Chapter 18:
Databases and
Information Systems

How data is organized into tables, connected through relationships, queried with SQL, and protected through transactions — the systems that power every school, hospital, bank, and website you use

■ Part IV: Computer Systems ■

■ 10 Sections  •  Chapter 18 of 28 ■

Follows Chapter 17: Software, Applications, and Development Tools  ·  Prepares for Chapter 19: Networks and the Internet

Chapter Purpose and Overview

Every time you search for a product online, check your grade in a school portal, look up a library book, withdraw money from an ATM, or log into a streaming service, a database is running behind the scenes. Databases are organized systems for storing, retrieving, updating, and protecting data. They are one of the most important technologies in modern computing — and yet, from the user's perspective, they are completely invisible.

This chapter introduces databases as systems, not merely as storage containers. You will learn how data is organized into tables, how rows and columns represent real-world records, how keys connect related information, how queries retrieve exactly the data you need, how SQL expresses those queries in a precise language, and how database management systems ensure that data stays consistent and reliable even when thousands of users access it at once.

The chapter also introduces information systems — the larger organizational structures that combine databases, software, people, and processes to support decision-making in schools, hospitals, banks, governments, stores, libraries, and every other institution that manages information.

Opening Question

When a student logs into a school portal and sees their grade for last week's assignment, what happened between clicking the login button and seeing that grade appear on screen? The answer involves a database receiving a query, searching millions of records in a fraction of a second, returning exactly the right information, and sending it to the browser — all without the student seeing any of it. Understanding that system is what this chapter is about.

10Sections
12Objectives
38Key Terms
4ACID Properties

Learning Objectives

  1. 1Explain what a database is and why organized data storage matters.
  2. 2Identify tables, records (rows), fields (columns), and data types in a relational database.
  3. 3Explain what primary keys and foreign keys are and why they are needed.
  4. 4Describe one-to-many and many-to-many relationships between tables.
  5. 5Explain what a query is and what kinds of operations queries perform.
  6. 6Read basic SQL SELECT statements and describe what they retrieve.
  7. 7Use WHERE, ORDER BY, and aggregate functions in SQL at an introductory level.
  8. 8Explain what a database management system (DBMS) does.
  9. 9Define a transaction and explain the ACID properties.
  10. 10Explain why backups and replication are important for reliability.
  11. 11Describe what an information system is and give examples of types.
  12. 12Connect database design to data governance and responsible information management.

Sections at a Glance

Sections 18.1 – 18.4
Structure: Tables, Records, Keys, and Relationships
Why Databases Matter · Tables · Keys · Relationships

Why Databases Matter

Before databases existed, organizations stored information in filing cabinets, paper ledgers, and card catalogs. A hospital might keep patient records in one cabinet, billing records in another, and appointment schedules in a third. Finding all the information about one patient required searching multiple places. Updating an address meant changing it in every location where it appeared. Mistakes were common. Information got lost.

Early computer programs tried to solve this by storing data in files — text files, spreadsheet files, or custom binary files. This was better than paper, but it still created problems. Each program managed its own files in its own format. Two programs that needed to share data had to copy information back and forth, which caused inconsistencies. If a student's address changed, the admissions program might be updated but the billing program might not. The same data existed in multiple places with different values. This problem is called data redundancy — the same information stored in multiple places in ways that can become contradictory.

A database solves these problems by providing a single organized system for storing and accessing data. Instead of scattered files managed by individual programs, a database creates a central repository with consistent structure, controlled access, and reliable retrieval.

What a Database Is

A database is an organized collection of related data. The data is structured so that it can be stored, searched, updated, and retrieved efficiently. A database is not just a pile of information — it is information arranged according to a design that reflects how the information relates to the real world.

A database management system, or DBMS, is the software that manages the database. The DBMS handles storing the data, executing queries, controlling access, maintaining consistency, and protecting the data from errors or corruption. Users and programs interact with the DBMS rather than directly with the raw data files. Together, the database and the DBMS form a database system.

Where Databases Appear

OrganizationWhat the Database Stores
SchoolStudent names, enrollment, grades, schedules, attendance, teacher assignments
HospitalMedical histories, test results, prescriptions, appointments, insurance, billing
BankAccount numbers, balances, transaction histories, customer information, loan records
Online storeProduct listings, prices, inventory, customer accounts, orders, shipping
LibraryBook titles, authors, ISBNs, shelf locations, borrower records, due dates
GovernmentCensus data, tax records, vehicle registrations, voter rolls, public benefits
Search engineIndexed web pages, links, rankings, and user data
Why Organization Matters

Disorganized data is almost as useless as no data at all. If a student named "James Smith" appears twice with different GPAs, which is correct? A well-designed database eliminates this by storing each piece of information exactly once and connecting pieces together through relationships — which is what the rest of this chapter explains.

Practice 18.1Concept Check
  1. In your own words, explain the difference between a database and a database management system. Use an analogy if it helps.
  2. What is data redundancy? Give an example from a school context where redundancy could cause a problem.
  3. Choose one type of organization from the table above. List three additional pieces of information its database would likely need to store beyond what is shown.

Tables, Records, and Fields

The most common type of database in business, education, and web development is the relational database. A relational database organizes information into tables that are connected by relationships. The concepts of tables, records, and fields are the foundation of everything that follows.

A table is a structured collection of related data organized into rows and columns. Each table represents one type of entity — one kind of thing the database stores information about. A school database might have a Students table, a Courses table, a Teachers table, and an Enrollments table. You would not mix student information and course information in the same table because they are different kinds of entities with different properties.

Records and Fields

Each row in a table is called a record. A record represents one instance of the entity the table describes. In a Students table, each row is one student. Each column is called a field. A field represents one property or attribute of the entity.

Example: Students Table
StudentID (PK) FirstName LastName GradeLevel GPA
1001MariaGarcia113.20
1002JamesObi103.75
1003PriyaSharma123.90
1004CarlosVega112.85
1005AikoTanaka103.40

Data Types and Constraints

Every field has a data type — the kind of value it is allowed to contain. Data types include Integer (whole numbers), Decimal or Float (numbers with decimal points), Text or String (character sequences), Date, and Boolean (true/false). Data types matter because they determine what operations are valid. You can calculate an average GPA because it is a number. You can sort LastName alphabetically because it is text.

Constraints are rules that the database enforces automatically. Common constraints include NOT NULL (a field must have a value), UNIQUE (no two records can share the same value in this field), and range constraints (GradeLevel might only permit values 9 through 12). Constraints enforce data quality without relying on whoever enters the data to remember the rules.

Database vs. Spreadsheet

A spreadsheet allows any value in any cell with little enforcement. A database table enforces consistent structure: every record has exactly the same fields, every field has a defined type, and constraints prevent illegal values. This strict structure is what makes reliable querying across millions of records possible.

Practice 18.2Tables, Records, Fields
  1. Using the Students table above: how many records does it contain? How many fields? What is the data type of the GPA field?
  2. A library database has a Books table. Suggest five fields it should contain, and for each field, specify an appropriate data type.
  3. Why would a NOT NULL constraint be important on the LastName field of a Students table? What would happen without it?
  4. Could a spreadsheet replace a database for storing 500,000 student records? What problems would arise?

Keys and Identifiers

One of the most important design decisions in a database is choosing how to uniquely identify each record. In a table of students, two students might have the same first name, or even the same full name. If you search for "James Smith," how does the database know which James Smith you mean? The solution is a key — a field whose value uniquely identifies each record.

Primary Keys

A primary key is a field whose value is unique for every record and never changes. In the Students table, StudentID is the primary key. Every student has a different StudentID. Even if two students are both named Maria Garcia, they will have different StudentIDs — perhaps 1001 and 2047 — and the database can distinguish them precisely.

Properties of a Good Primary Key

• Unique — No two records share the same primary key value.

• Never null — Every record must have a primary key value.

• Stable — The primary key does not change after it is assigned.

• Simple — A single field is preferred over a combination of fields.

Natural Keys vs. Surrogate Keys

A natural key is drawn from real-world data that naturally identifies the entity — for example, an ISBN for a book. A surrogate key is an artificial identifier created by the database, such as StudentID: 1001. Surrogate keys are often preferred because real-world identifiers can change (a person's name, email, or phone number) while surrogate keys never need to be updated. Once 1001 is assigned to Maria Garcia, it stays with her record permanently.

Foreign Keys and Referential Integrity

A foreign key is a field in one table that refers to the primary key of another table. Foreign keys create connections between tables. Consider a Courses table with a TeacherID field — TeacherID is a foreign key that references the TeacherID primary key in the Teachers table. Each course record points to the teacher who teaches it.

Referential integrity is the rule that every foreign key value must match a real primary key in the referenced table. If a foreign key in the Enrollments table contains StudentID 9999, but there is no student with ID 9999 in the Students table, the DBMS rejects that record. This prevents orphaned records — records that refer to things that do not exist.

Example: Courses Table with Foreign Key
CourseID (PK)CourseNameTeacherID (FK)
C101Introduction to CST07
C102Algebra IIT12
C103World HistoryT03

Gold = Primary Key (PK)  ·  Teal = Foreign Key (FK) referencing Teachers.TeacherID

Practice 18.3Keys and Identifiers
  1. In the Students table from Section 18.2, which field is the primary key? Could FirstName + LastName serve as a primary key? Explain why or why not.
  2. Explain the difference between a natural key and a surrogate key. Give one example of each from a different context than the textbook.
  3. A foreign key in an Orders table contains CustomerID: 8847, but there is no customer with that ID in the Customers table. What does referential integrity do in this situation? Why is that the correct behavior?
  4. Why should primary keys never change after being assigned? Give a real-world scenario where changing a primary key would cause problems.

Relationships Between Tables

The power of a relational database comes from relationships — the connections between tables that allow you to combine information from multiple sources in a single query. There are three fundamental types of relationships.

One-to-Many

A one-to-many relationship means that one record in Table A can be associated with many records in Table B, but each record in Table B is associated with only one record in Table A. One teacher can teach many courses, but each course has only one teacher. The foreign key lives in the "many" side of the relationship — TeacherID lives in the Courses table, not the Teachers table.

Many-to-Many

A many-to-many relationship means that records in each of two tables can be associated with multiple records in the other. One student can enroll in many courses, and one course can have many students enrolled. Many-to-many relationships cannot be stored directly with two tables alone. They require a junction table — a linking table that sits between the two main tables and holds foreign keys to both.

Many-to-Many: Students ↔ Courses through Enrollments
LoanID (PK)StudentID (FK)CourseID (FK)
E0011001C101
E0021001C102
E0031002C101
E0041003C103

The Enrollments table is the junction table. Each row records one enrollment — one student in one course. Student 1001 (Maria) is enrolled in both C101 and C102. Course C101 has both student 1001 and 1002. By searching this table, you can find all courses a student is in, or all students in a course.

One-to-One

A one-to-one relationship means each record in Table A is associated with exactly one record in Table B, and vice versa. These are less common and are sometimes used to split a large table for performance, or to separate sensitive information from general information.

Entity-Relationship Diagrams

Database designers use Entity-Relationship Diagrams (ER Diagrams) to plan a database's structure visually before writing any code. An ER Diagram shows the tables (entities), their fields (attributes), primary keys, and the relationships between tables. Reading ER Diagrams is a foundational skill for any database work.

Simplified ER Diagram: School Database
  [Students]         [Enrollments]         [Courses]
  +-----------+      +-----------+-------+  +----------+
  |StudentID  |◄─────|StudentID  |CourseID|─►|CourseID  |
  |FirstName  |      +-----------+-------+  |CourseName|
  |LastName   |      (junction table)        |TeacherID |──►[Teachers]
  |GradeLevel |                              +----------+   |TeacherID|
  |GPA        |                                             |Name     |
  +-----------+                                             +---------+

  ◄── = foreign key reference
  one-to-many: one Teacher teaches many Courses
  many-to-many: Students ↔ Courses through Enrollments
Practice 18.4Relationships
  1. Classify each relationship below as one-to-many or many-to-many, and explain your reasoning:

    a. One author can write many books; each book has one primary author.
    b. Students can check out many library books over time; the same book can be checked out by many students across time.
    c. One department can have many employees; each employee belongs to one department.
  2. Design a junction table for a many-to-many relationship between Actors and Films. What fields would this table contain? What would a primary key for this table look like?
  3. Why can a many-to-many relationship not be stored using just two tables and a single foreign key?
Sections 18.5 – 18.6
Queries and SQL: Asking Questions of a Database
What Queries Do · SQL SELECT · WHERE · ORDER BY · Aggregates · JOIN

Queries

A query is a request for data from a database. Queries are the primary way that users and programs interact with a database. A query specifies what data you want, where to find it, what conditions it must meet, and how to organize the results.

What Queries Do

OperationWhat It DoesPlain-English Example
SelectionFilter which rows are returned based on a condition"Give me all students in grade 11."
ProjectionChoose which columns appear in the result"Show me only first name and last name."
JoiningCombine rows from multiple tables into one result"Show each student's name and their courses."
AggregationCompute statistics across records"What is the average GPA of 10th graders?"
SortingOrder results by one or more fields"List all students alphabetically by last name."
InsertionAdd new records to a table"Add a new student: Leon Mbeki, grade 12."
UpdateModify existing records"Change Maria Garcia's GPA to 3.30."
DeletionRemove records from a table"Remove the record for student ID 1004."

The result of a retrieval query is a result set — a temporary table containing the records and fields that match the query. This result set is shown to the user or processed by a program. It is a view of the data, not a stored copy — querying does not change what is in the database.

Every time you search for a product, look up your grades, see a recommended list, or log in to a personalized homepage, a query is executing behind the scenes. The web application sends a query to the database, receives a result set, and uses that data to build what you see on screen.

Practice 18.5Query Operations
  1. For each scenario, identify the type of query operation (selection, projection, joining, aggregation, sorting, or a combination):

    a. "Show me the names of all students who borrowed a book in the last 30 days."
    b. "What is the total value of all orders placed this month?"
    c. "Show me each employee's name, their department name, and their manager's name."
    d. "List all products sorted from most expensive to least expensive."
  2. A result set is not stored back in the database. Explain in your own words what this means and why it is important.

SQL at an Introductory Level

SQL — pronounced either "S-Q-L" or "sequel" — stands for Structured Query Language. SQL is the standard language for communicating with relational databases. It is used to create tables, insert data, query data, update records, and delete records.

SQL is a declarative language — you describe what you want, and the database figures out how to retrieve it. You do not write step-by-step loops; you state your request, and the DBMS executes it. SQL is one of the most widely used languages in computing, and learning its basics gives you a skill that applies across dozens of database systems.

SELECT — Retrieving Data

The SELECT statement retrieves data. Its basic form specifies which columns to return and which table to read from. To retrieve all columns, use * (asterisk, meaning "all").

SELECT: Retrieve first and last names of all students
SELECT FirstName, LastName
FROM Students;
Result:
FirstNameLastName
MariaGarcia
JamesObi
PriyaSharma
CarlosVega
AikoTanaka

WHERE — Filtering Rows

The WHERE clause filters which rows are included. It supports comparison operators =, <, >, <=, >=, <> (not equal), and logical operators AND, OR, and NOT.

WHERE: Grade 11 students with GPA above 3.0
SELECT FirstName, LastName, GPA
FROM Students
WHERE GradeLevel = 11 AND GPA > 3.0;
Result:
FirstNameLastNameGPA
MariaGarcia3.20

ORDER BY — Sorting Results

ORDER BY: All students sorted by GPA, highest first
SELECT FirstName, LastName, GPA
FROM Students
ORDER BY GPA DESC;
Result:
FirstNameLastNameGPA
PriyaSharma3.90
JamesObi3.75
AikoTanaka3.40
MariaGarcia3.20
CarlosVega2.85

DESC sorts descending (highest to lowest). ASC sorts ascending (lowest to highest) and is the default.

Aggregate Functions

SQL provides built-in functions for computing statistics across records. These are called aggregate functions.

FunctionWhat It ComputesExample
COUNT(*)Number of recordsHow many students total?
AVG(column)Average of a numeric fieldAverage GPA?
SUM(column)Total of a numeric fieldTotal hours logged?
MAX(column)Highest valueHighest GPA in the school?
MIN(column)Lowest valueLowest GPA?
Aggregate + GROUP BY: Average GPA per grade level
SELECT GradeLevel, AVG(GPA) AS AverageGPA, COUNT(*) AS StudentCount
FROM Students
GROUP BY GradeLevel
ORDER BY GradeLevel;
Result:
GradeLevelAverageGPAStudentCount
103.5752
113.0252
123.9001

JOIN — Combining Tables

The JOIN clause combines rows from two tables based on a related column. This is the feature that makes relational databases powerful — it allows you to retrieve connected information from multiple tables in one query.

JOIN: Each student's name and their enrolled courses
SELECT Students.FirstName, Students.LastName, Courses.CourseName
FROM Students
JOIN Enrollments ON Students.StudentID = Enrollments.StudentID
JOIN Courses ON Enrollments.CourseID = Courses.CourseID
ORDER BY Students.LastName;
Result:
FirstNameLastNameCourseName
MariaGarciaIntroduction to CS
MariaGarciaAlgebra II
JamesObiIntroduction to CS
PriyaSharmaWorld History

INSERT, UPDATE, DELETE

Modifying Data
-- Add a new student record
INSERT INTO Students (StudentID, FirstName, LastName, GradeLevel, GPA)
VALUES (1006, 'Leon', 'Mbeki', 12, 3.65);

-- Update an existing record
UPDATE Students
SET GPA = 3.30
WHERE StudentID = 1001;

-- Remove a record
DELETE FROM Students
WHERE StudentID = 1004;
Critical Warning — Always Use WHERE with UPDATE and DELETE

Running UPDATE Students SET GPA = 4.0 without a WHERE clause sets every student's GPA to 4.0. Running DELETE FROM Students without a WHERE clause deletes every student. Always double-check that your WHERE condition is correct before running UPDATE or DELETE.

Practice 18.6Reading SQL
  1. Read this query and answer the questions below:
    SELECT FirstName, LastName, GPA
    FROM Students
    WHERE GradeLevel = 10
    ORDER BY GPA DESC;
    a. Which table is being queried?
    b. Which fields will appear in the result?
    c. Which students from the sample table (Section 18.2) will appear in the result?
    d. In what order will they appear?
  2. Write a plain-English description of what this query does:
    SELECT COUNT(*) FROM Students WHERE GradeLevel = 12;
  3. A developer writes this UPDATE statement:
    UPDATE Students
    SET GradeLevel = 12;
    What is the result? What should the developer have written instead?
  4. Manually compute the result of this query using the sample data from Section 18.2:
    SELECT GradeLevel, COUNT(*), AVG(GPA)
    FROM Students
    GROUP BY GradeLevel;
Sections 18.7 – 18.10
Database Systems, Reliability, and Organizations
DBMS · Transactions · ACID · Backups · Information Systems

Database Management Systems

A database management system (DBMS) is the software layer that sits between users or applications and the raw data stored on disk. Users and programs never interact directly with data files; they always go through the DBMS, which handles all the complexity of actually storing and retrieving data.

What a DBMS Does

ResponsibilityWhat the DBMS Handles
Storage managementOrganizes data on disk in efficient structures; maintains indexes for fast retrieval
Query processingParses SQL, creates an execution plan, runs the query, returns the result set
Access controlEnforces permissions — read, write, admin — for different users and roles
Concurrency controlCoordinates simultaneous access by multiple users without conflicts
Transaction managementEnsures groups of operations either fully succeed or fully cancel
Integrity enforcementEnforces data types, constraints, primary keys, foreign keys, referential integrity
RecoveryRestores a consistent state after a crash, without leaving data partially written

Common Database Systems

Relational DBMSs (RDBMS) store data in tables with SQL as the query language. They are the most common type for business and web applications. Major relational database systems include MySQL (widely used for web applications; open-source), PostgreSQL (powerful open-source system known for standards compliance), SQLite (a lightweight single-file database common in mobile apps and small applications), Microsoft SQL Server (enterprise RDBMS used in many business systems), and Oracle Database (used in large organizations).

NoSQL DBMSs store data in formats other than tables — documents, key-value pairs, graphs, or wide columns. They are used when data does not fit well into a tabular structure or when extreme scale is required. Examples include MongoDB (document store) and Redis (key-value store). NoSQL systems are beyond the scope of this chapter, but they are important to know exist.

How Applications Use a DBMS

Web Application — Database Architecture
  User (Browser)
       │
       │  HTTP request: "Add item to cart"
       ▼
  Web Server
  (Application Code: Python / Node / Java / etc.)
       │
       │  SQL: INSERT INTO Cart (UserID, ItemID) VALUES (42, 789);
       ▼
  Database Management System (DBMS)
  ┌─────────────────────────────────────────┐
  │  Parses SQL → Creates execution plan    │
  │  Enforces constraints → Runs query      │
  │  Manages transaction → Returns result   │
  └─────────────────────────────────────────┘
       │
       │  Reads / writes data files
       ▼
  Storage (SSD / Hard Drive)
  [Data files · Indexes · Transaction logs]

The DBMS is invisible to the user but essential to every operation. When you click "add to cart," log in, search a catalog, or update your profile, a DBMS is handling the underlying data operations in the background.

Practice 18.7DBMS Concepts
  1. List three responsibilities of a DBMS and explain why each matters. For each one, describe what could go wrong if the DBMS did not handle it.
  2. When you log in to a streaming service and see your "continue watching" list, describe the sequence of events involving the DBMS. Include the query that might be sent.
  3. What is the difference between a relational DBMS and a NoSQL DBMS? Give a use case where each type would be appropriate.

Transactions and Consistency

One of the most important and subtle problems in database design is ensuring that the data remains correct when multiple operations happen together — especially when something goes wrong in the middle.

The Bank Transfer Problem

The Problem Without Transactions
A bank transfers $500 from checking to savings: two operations required
  • Step 1Subtract $500 from the checking account balance
  • Step 2Add $500 to the savings account balance
  • ProblemWhat if the system crashes after Step 1 but before Step 2? Checking has been debited $500, but savings has not been credited. $500 has disappeared.
  • ConclusionBoth operations must either both succeed or both fail. There is no acceptable half-completed state. This is what a transaction enforces.

Transactions: Commit and Rollback

A transaction is a group of database operations that are treated as a single unit. A transaction either commits — all operations complete successfully and changes are permanently saved — or rolls back — all operations are cancelled and the database returns to its state before the transaction began.

The Bank Transfer as a Transaction
BEGIN TRANSACTION;

UPDATE Accounts
SET Balance = Balance - 500
WHERE AccountID = 'CHK-001';

UPDATE Accounts
SET Balance = Balance + 500
WHERE AccountID = 'SAV-001';

COMMIT;  -- makes all changes permanent

If the system crashes between the two UPDATE statements, the DBMS rolls back the transaction on recovery, undoing the first UPDATE. The database returns to the pre-transfer state. No money is lost or created.

Transaction Lifecycle
  BEGIN TRANSACTION
         │
         ▼
    [Operation 1] ──FAIL──► ROLL BACK
         │                  (database returns to
         ▼                   pre-transaction state)
    [Operation 2] ──FAIL──► ROLL BACK
         │
         ▼
    [Operation N]
         │
         ▼
       COMMIT
  (all changes permanent)

The ACID Properties

Database transactions are designed to guarantee four properties, summarized by the acronym ACID.

A
Atomicity
All operations in a transaction succeed, or none do. There is no partial execution. (From "atom" — indivisible.)
C
Consistency
A transaction takes the database from one valid state to another. All constraints and relationships remain intact.
I
Isolation
Concurrent transactions behave as if they run one at a time. One transaction cannot see the incomplete state of another.
D
Durability
Once a transaction commits, its changes are permanent — even if the system crashes immediately after the commit.
Worked Example 18.2
Race condition: Two customers, one last seat
  • Without isolationCustomer A reads: seats available = 1. Customer B reads: seats available = 1. Both proceed. Both book. Result: two bookings for one seat. Double-booked.
  • With isolationCustomer A's transaction begins and locks the row. Customer B's transaction must wait. Customer A commits. Seats = 0 is now permanent. Customer B reads: seats = 0. Condition fails. Customer B is told no seats are available.
  • ResultOne booking for one seat. No double-booking. Isolation prevents the race condition.
Isolation: concurrent transactions cannot interfere with each other's intermediate state.
Practice 18.8Transactions and ACID
  1. In your own words, explain the difference between "commit" and "rollback" in a database transaction.
  2. Which ACID property protects against the bank transfer problem described in this section? Explain why.
  3. A hospital records a patient's medication dosage in two separate tables — the Prescriptions table and the Administration Log. Explain why this update should be wrapped in a transaction, and what could go wrong if it were not.
  4. ACID compliance requires careful engineering in a DBMS. Why do you think financial, medical, and legal databases prioritize ACID compliance above almost everything else?

Backups and Reliability

Even a perfectly designed database with ACID transactions can lose data if hardware fails, software has bugs, a fire destroys a data center, or a ransomware attack encrypts the data files. Backups are copies of the database that can be used to restore data if the original is lost or corrupted. ACID guarantees consistency within a running system; backups guarantee survival when the system itself is destroyed.

Types of Backups

Backup TypeWhat It CopiesAdvantageDisadvantage
Full backupThe entire database at a point in timeSimple to restore — one copy is all you needSlow and storage-intensive for large databases
Incremental backupOnly data changed since the last backupFast, small filesRestoration requires last full backup plus every incremental since
Differential backupAll data changed since the last full backupGrows over time but simpler to restore than incrementalGrows larger the longer you wait between full backups
Transaction log backupThe record of every transaction, continuouslyAllows recovery to almost any point in timeRequires more storage and management

Key Reliability Measures

Organizations must decide how often to take backups, how long to keep them, and where to store them. Storing backups on the same server as the database is dangerous — if the server fails, the backup fails too. Reliable systems store backups in separate physical locations or in cloud storage.

Two key measures guide backup strategy. Recovery Point Objective (RPO) is how much data is acceptable to lose in the worst case — if you back up every hour, you could lose up to one hour of data. Recovery Time Objective (RTO) is how long it takes to restore service after a failure.

Replication goes beyond backups by maintaining one or more real-time copies of the database on separate servers. If the primary server fails, a replica takes over immediately, minimizing downtime. High-reliability database systems — used by banks, hospitals, airlines, and large web services — combine ACID-compliant transactions, multiple levels of backup, geographic replication, and regular recovery drills to verify that backups actually work.

Testing Backups

Making backups is not enough. Organizations must regularly test that their backups can actually be restored. A backup that cannot be restored is not a backup — it is a false sense of security. Discovering a backup is corrupted during an actual disaster is far worse than discovering it during a routine test.

Practice 18.9Backups and Reliability
  1. A small school takes a full backup every Sunday night at 11 PM and uses no other backup method. The database is corrupted at Friday 4 PM. How much data could be lost? What would you recommend to reduce this risk?
  2. Explain the difference between a backup and replication. Which protects against accidental data deletion? Which protects against server hardware failure?
  3. Why is it dangerous to store database backups on the same physical server as the database itself?

Information Systems in Organizations

A database is a technical system — it stores data and answers queries. But databases do not exist in isolation. They are embedded in information systems — larger systems that combine databases, software applications, user interfaces, networks, people, processes, and policies to support the work of organizations.

An information system is more than software. It includes data (the information itself), hardware (servers, computers, storage), software (the DBMS, application programs, interfaces), people (users, administrators, developers, decision-makers), processes (the workflows and procedures that govern how information is collected and used), and policies (rules about who can access what, how long data is retained, and what can be done with it).

Types of Information Systems

TypePurposeExample
Transaction Processing System (TPS)Records day-to-day operations as they happenPoint-of-sale system; bank ATM transactions; hospital patient check-in
Management Information System (MIS)Summarizes transaction data into reports for managersMonthly sales report by region; quarterly inventory summary
Decision Support System (DSS)Helps analysts explore data and model scenarios"What if we cut prices by 10% — how would revenue change?"
Customer Relationship Management (CRM)Stores customer interactions, purchases, and support historySalesforce; help desk systems that show a customer's history
Enterprise Resource Planning (ERP)Integrates all organizational data — accounting, HR, inventory, purchasing — into one systemSAP; large manufacturers using one system for all departments

Database Administrators

Database administrators (DBAs) are the specialists who design, maintain, and protect database systems. Their responsibilities include designing database schemas, writing and optimizing queries, managing user permissions, monitoring performance, planning backup and recovery procedures, applying security patches, and ensuring compliance with data privacy regulations. Database administration is a specialized career path within computing, covered further in Chapter 28.

Data Governance and Policy

Organizations must make decisions about how their data is governed. Who is allowed to access which tables and fields? How long is data retained before deletion? What regulations apply — for example, student records are governed by FERPA in the United States, and medical records are governed by HIPAA. How is sensitive data (Social Security numbers, medical diagnoses, financial details) protected? Who is responsible when data is lost, stolen, or misused?

These are not purely technical questions — they are legal, ethical, and organizational questions. The database is the technical system; data governance is the human system that determines how the database is used responsibly. Understanding data governance connects directly to Chapter 22 (Privacy, Identity, and Digital Safety) and Chapter 28 (Ethics, Society, Careers, and the Future of Computing).

Practice 18.10Information Systems
  1. Classify each of these as a TPS, MIS, DSS, CRM, or ERP system and explain your reasoning:

    a. A system that shows a customer service agent every purchase, complaint, and return for the customer currently on the phone.
    b. A system that records each sale the instant a customer checks out at a grocery store.
    c. A system used by a hospital to manage payroll, supply ordering, billing, and patient scheduling all in one place.
    d. A system that lets a retail chain's executives see projected revenue under different pricing scenarios.
  2. A school stores student medical records, grades, and disciplinary records all in one shared database. Three different staff members — a nurse, a teacher, and an administrator — need access to different parts of this data. Describe a data governance policy that would control access appropriately.

Chapter Summary

Key Terms Review

ACID
The four properties of reliable transactions: Atomicity, Consistency, Isolation, and Durability.
aggregate function
A SQL function that computes a summary value across records: COUNT, AVG, SUM, MAX, MIN.
atomicity
All operations in a transaction succeed, or none do. No partial execution.
backup
A copy of database data made so it can be restored if the original is lost or corrupted.
commit
The action that makes a transaction's changes permanent in the database.
consistency
A transaction takes the database from one valid state to another; all constraints remain intact.
constraint
A rule enforced by the database on field values, such as NOT NULL, UNIQUE, or data type limits.
data governance
Organizational policies determining how data is accessed, retained, protected, and used responsibly.
data redundancy
The same information stored in multiple places, which can lead to inconsistencies.
data type
The kind of value a field is permitted to hold: integer, decimal, text, date, boolean, etc.
database
An organized collection of related data structured for efficient storage, retrieval, and management.
database administrator
A specialist who designs, maintains, optimizes, and protects database systems.
DBMS
Database management system — software that manages the database, handling storage, queries, concurrency, integrity, and recovery.
durability
Committed changes survive system crashes and are permanently stored.
ER Diagram
Entity-Relationship Diagram — a visual plan of a database's tables, fields, and relationships.
field
A column in a database table representing one attribute of the entity being described.
foreign key
A field in one table that references the primary key of another table, creating a relationship.
information system
A system combining database, software, hardware, people, processes, and policies to collect, store, and distribute information for an organization.
isolation
Concurrent transactions behave as if they run one at a time; no transaction sees another's incomplete state.
JOIN
A SQL clause that combines rows from two or more tables based on a related column.
junction table
A table used to implement a many-to-many relationship by holding foreign keys to both related tables.
many-to-many
A relationship where records in each of two tables can be associated with multiple records in the other.
one-to-many
A relationship where one record in Table A can be associated with many records in Table B, but not vice versa.
primary key
A field that uniquely identifies each record in a table and never changes.
query
A request for data from a database specifying what to retrieve, from where, under what conditions, and in what order.
record
A row in a database table representing one instance of the entity being stored.
referential integrity
The rule that every foreign key value must match a valid primary key in the referenced table.
relational database
A database organized into tables connected by relationships, queried using SQL.
replication
Maintaining synchronized copies of a database on separate servers for reliability and performance.
result set
The temporary table of records returned by a query; a view of the data, not a stored copy.
roll back
Cancelling all operations in a transaction and returning the database to its previous state.
SQL
Structured Query Language — the standard language for querying and manipulating data in relational databases.
surrogate key
An artificial primary key created by the database that has no meaning outside the database.
table
A structured collection of related data organized into rows and columns in a relational database.
transaction
A group of database operations treated as a single unit that either fully commits or fully rolls back.

Diagram Review

Diagram 18-A: Relational Table Anatomy
  Table: Students
  ┌══════════════╤═══════════╤══════════╤════════════╤════════
  │ StudentID    │ FirstName │ LastName │ GradeLevel │ GPA   │
  │ (PK INTEGER) │ (TEXT)    │ (TEXT)   │ (INTEGER)  │(REAL) │
  ╞══════════════╪═══════════╪══════════╪════════════╪═══════╡
  │ 1001         │ Maria     │ Garcia   │ 11         │ 3.20  │
  │ 1002         │ James     │ Obi      │ 10         │ 3.75  │
  │ 1003         │ Priya     │ Sharma   │ 12         │ 3.90  │
  └──────────────┴───────────┴──────────┴────────────┴───────┘
       ↑                                                 ↑
   Primary Key                                      Data Type
   (unique, not null,                               REAL = decimal
    never changes)                                  numbers allowed

  Each ROW = one record (one student)
  Each COLUMN = one field (one attribute)
  PK = Primary Key · TEXT/INTEGER/REAL = data types
Diagram 18-B: Three-Table School Database
  Students                Enrollments (junction)       Courses
  ┌────────────┐          ┌────────────┬──────────┐    ┌──────────┬───────────────────┐
  │ StudentID  │◄─────────│ StudentID  │ CourseID │────►│ CourseID │ CourseName        │
  │ FirstName  │    FK    │ (FK)       │ (FK)     │ FK │ TeacherID│                   │
  │ LastName   │          └────────────┴──────────┘    └──────────┴───────────────────┘
  │ GradeLevel │                                                │
  │ GPA        │                                                │ FK
  └────────────┘                                                ▼
                                                          Teachers
                                                          ┌──────────┬──────────┐
                                                          │ TeacherID│ Name     │
                                                          └──────────┴──────────┘

  ◄──── = foreign key reference pointing to a primary key
  one-to-many: one Teacher → many Courses
  many-to-many: Students ↔ Courses (through Enrollments junction table)

Code Review

Code Review 18-1: Reading a SELECT Query

SELECT FirstName, LastName, GPA
FROM Students
WHERE GradeLevel = 10
ORDER BY GPA DESC;
  1. Which table is this query reading from?
  2. Which three fields will appear in the result?
  3. What condition must a record meet to be included?
  4. How will the results be ordered? What does DESC mean?
  5. Trace the query against the Students table from Section 18.2. Which students appear in the result, and in what order?

Code Review 18-2: Reading a JOIN Query

SELECT Students.FirstName, Students.LastName, Courses.CourseName
FROM Students
JOIN Enrollments ON Students.StudentID = Enrollments.StudentID
JOIN Courses ON Enrollments.CourseID = Courses.CourseID
WHERE Courses.CourseName = 'Introduction to CS';
  1. How many tables does this query use?
  2. What is the purpose of each JOIN condition?
  3. Using the sample data from this chapter, what result would this query produce?
  4. Explain in plain English what this query is asking for.

Code Review 18-3: Aggregate and GROUP BY

SELECT GradeLevel, COUNT(*) AS StudentCount, AVG(GPA) AS AverageGPA
FROM Students
GROUP BY GradeLevel
ORDER BY GradeLevel;
  1. What does COUNT(*) compute? What does AVG(GPA) compute?
  2. What does AS StudentCount do in the result?
  3. What does GROUP BY GradeLevel do? Why is it necessary here?
  4. Compute the result manually using the sample data from Section 18.2.

Practice Questions

Section AVocabulary in Context

Complete each sentence with the correct term from the chapter.

  1. A ____________ is the field that uniquely identifies each record in a table and never changes.
  2. A ____________ is a field in one table that refers to the primary key of another table.
  3. The rule that every foreign key value must match a valid primary key is called ____________.
  4. A ____________ groups multiple database operations into a single unit that either fully succeeds or fully cancels.
  5. ____________ is the ACID property that ensures committed changes survive a system crash.
  6. A ____________ is used to implement a many-to-many relationship between two tables.
  7. The SQL clause that filters which rows appear in a result is ____________.
  8. The SQL clause that combines rows from two tables based on a related field is ____________.
Section BShort Answer
  1. A Students table has fields: StudentID, FirstName, LastName, GradeLevel, Email, GPA. Which field would make the best primary key? Could Email serve as a primary key? Explain.
  2. A school has a Teachers table and a Courses table. Each course has exactly one teacher; one teacher can teach multiple courses. What type of relationship is this? Where would the foreign key be placed?
  3. Describe in plain English what this query does:
    SELECT CourseName FROM Courses WHERE TeacherID = 'T07';
  4. What is the difference between a full backup and an incremental backup? What is the advantage of each?
  5. Explain in your own words the difference between a database and an information system.
Section CAnalysis and Application
  1. Consider an online store. List at least four tables that its database would likely need, and for each table suggest two or three fields it would contain. Identify primary keys and at least one foreign key relationship between tables.
  2. Explain why storing teacher names directly in the Courses table as a text field (TeacherName: "Rivera") is worse than storing a foreign key (TeacherID: "T07"). What specific problem arises when the teacher's name changes?
  3. An airline reservation system must ensure that only one customer can book the last available seat on a flight. Explain how transactions and the ACID property of isolation prevent two customers from both successfully booking the same seat simultaneously.
  4. A nonprofit collects this information about volunteers: name, email, phone, date joined, hours volunteered per month, and projects they work on (each volunteer may work on multiple projects; each project has multiple volunteers). Design a database with appropriate tables. Describe tables, fields, primary keys, and any foreign keys or junction tables needed.

Error Analysis

Error 18-1
SELECT FirstName FROM Students WHERE GradeLevel = 11 WHERE GPA > 3.0;

What is wrong with this SQL? How should it be corrected?

Error 18-2 — Missing WHERE clause
UPDATE Students SET GPA = 4.0;

What is the result of this statement? What should the developer have written to update only student ID 1003?

Error 18-3 — Referential integrity violation
INSERT INTO Enrollments (StudentID, CourseID) VALUES (9999, 'C101');
/* There is no student with ID 9999 in the Students table */

What happens when the DBMS processes this statement? What database concept causes this behavior, and why is the behavior correct?

Error 18-4 — Combining unlike data
A developer creates one table with fields: OrderID, CustomerName, CustomerEmail, ProductName, ProductPrice, Quantity, OrderDate. This table stores all customer, order, and product data together.

Identify two specific problems this design causes. How would splitting into separate, related tables solve these problems?

Error 18-5 — Backup stored on the same server
A company's only database backup is stored on the same physical server as the database. The server is destroyed in a fire.

What happens to the backup? What backup strategy would have prevented total data loss?

Design and Application Questions

  1. Design 18-1: Design a database for a small public library. Identify at least three tables. For each table, list fields, identify the primary key, and describe at least one relationship between tables. Sketch a simple ER Diagram using the notation from this chapter.
  2. Design 18-2: A school wants to track student attendance electronically. Design a database table or tables to store this information. Consider what fields are needed, how absences and tardies would be distinguished, and how attendance would be linked to students and specific class periods.
  3. Design 18-3: Write SQL queries (or describe them in plain English) for the following requests against the school database from this chapter:

    a. Find the names of all students with a GPA above 3.5.
    b. Count how many students are in each grade level.
    c. Find the names of all courses that Maria Garcia (StudentID 1001) is enrolled in.
    d. Find the average GPA of all students in the database.
  4. Design 18-4: A hospital database stores patient records, doctor information, and appointments. Each appointment is between one patient and one doctor; each patient can have many appointments with different doctors; each doctor can have many appointments with different patients. What type of relationship exists between patients and doctors? Design the tables and explain your choices.

Real-World Applications

  1. When you log into a website — a school portal, streaming service, or email — and enter your username and password, what database operations are likely happening behind the scenes? Describe the process step by step, including what query is sent and what the DBMS returns.
  2. An airline wants to show available seats when you search its website. What tables might its database contain? What query would the website need to run to show available flights between two cities on a given date?
  3. During a major online sale event, millions of customers are purchasing products simultaneously. Explain two ways that database design — transactions and concurrency control — protects against errors during this high-traffic event.
  4. A hospital uses a database to store patient medical records. Describe three different user roles who might access this database and the level of access each should have. What database feature enforces these access levels?
  5. A city stores property tax records in a database. A homeowner moves and needs to update their mailing address. Explain why it is better to store the homeowner's address in one place — their record in a Homeowners table — rather than in every tax record associated with them.

Chapter 18 Checkpoint

Chapter 18 Checkpoint
Complete without assistance — assesses all key concepts from Chapter 18
Section 1 — Vocabulary and Concepts
  1. What is a relational database? How is it different from a spreadsheet?
  2. Explain the difference between a primary key and a foreign key. Give one example of each.
  3. What does referential integrity mean? What problem does it prevent?
  4. Describe the three types of table relationships. For each one, give a real-world example.
Section 2 — SQL Reading
  1. What does this query return? SELECT * FROM Students WHERE GPA >= 3.75;
  2. What does this query return? SELECT COUNT(*) FROM Students WHERE GradeLevel = 10;
  3. This query has an error. Identify and correct it: SELECT FirstName FROM Students WHERE GradeLevel = 11 WHERE GPA > 3.0;
Section 3 — Transactions and Reliability
  1. What are the four ACID properties? Define each one in one sentence.
  2. A system crashes while processing a bank transfer, partway through the transaction. What does the DBMS do when it recovers? Which ACID property guarantees this?
  3. What is the difference between a backup and replication? When would each be most useful?
Section 4 — Design
  1. Design a minimal database (two or three tables) to track books and borrowers for a small library. Describe each table's fields and primary key, and show at least one foreign key relationship.
  2. A developer runs DELETE FROM Students; without a WHERE clause. What happens? What should they have done instead?
Section 5 — Systems
  1. What is an information system? How is it broader than a database?
  2. Classify a point-of-sale system at a grocery store. Which type of information system is it? What data does it record?
  3. Why is data governance important? Give one example of a policy decision an organization must make about its database.

Mixed Review

These questions draw on earlier chapters of the textbook.

  1. (Chapter 14) A CSV file and a database table can both store information in rows and columns. What are two advantages a database table has over a CSV file for storing data that is frequently updated and queried?
  2. (Chapter 13) A database is an example of abstraction. What detail does the database hide from programs and users that query it? What interface does it provide instead?
  3. (Chapter 12) A database uses an index on a field to speed up searches. How is this conceptually similar to binary search? What tradeoff does adding an index create?
  4. (Chapter 10) A developer accidentally deletes all records from a critical table by omitting a WHERE clause. What kind of error is this — syntax, runtime, or logic? Why is a logic error particularly dangerous in a database context?
  5. (Chapter 9) SQL functions like COUNT(), AVG(), and SUM() are similar to functions in a programming language. What do they have in common? How do they differ in how they are called and what they return?
Looking Ahead
Chapter 19 — Networks and the Internet

Chapter 19 begins Part V: Networks, Web, and Security. You have now seen how data is organized and stored in databases on servers. But how does a request from your laptop or phone reach a database server halfway across the world? Chapter 19 explains how computers communicate across networks — through nodes, links, packets, routers, and protocols. You will learn what an IP address is, how domain names are translated into addresses, how protocols govern communication, and how the internet itself is structured as a network of networks. These concepts explain the infrastructure that delivers every web page, database query result, and streaming video you receive.

MGU Library Connection
  • Appendix F: Data Structures and Algorithms Reference — for tables as data structures
  • Appendix J: Data Science and AI Reference — datasets, features, and data cleaning connect here
  • Chapter 14: Files, Tables, and Data Processing — introduction to CSV and tabular data
  • Chapter 22: Privacy, Identity, and Digital Safety — data governance and personal data protection
  • Chapter 28: Ethics, Society, Careers, and the Future — database careers and responsible data use
  • MGU Databases and SQL Foundations — the follow-on course for full SQL and database design