Chapter 5: Relational Database

Book A2 - Information ProcessingChapter 5
BOOK A2 • CHAPTER 5

Relational Database Systems (RDBMS)

Databases provide structured, multi-user storage with strict data integrity, normalized table relationships, automated SQL querying, and zero data redundancy.

Relational Database Architecture Visual
5.1

Database vs. Spreadsheet

  • Database Management System (DBMS): Software that creates, manages, and queries structured relational data (e.g., MS Access, MySQL).
  • Database vs. Spreadsheet:
    • • Spreadsheet: Best for quick single-user calculations and visual charts.
    • • Database: Best for multi-user, massive data volumes, multi-table queries, and enforcing data integrity.
  • Eliminating Data Redundancy: Relational structures prevent duplicate data entries, avoiding insertion, deletion, and update anomalies.
5.2

Database Objects

📋 TableStores raw records in rows (tuples) and fields in columns (attributes).
🔍 QueryRetrieves, filters, sorts, and transforms specific data from tables.
🖼️ FormUser-friendly visual UI for data entry and record editing.
🖨️ ReportFormatted print/export layout summarizing database information.
5.3

Database Keys & Field Properties

  • Primary Key (PK): A field that uniquely identifies each record in a table. Must NOT be Null and must contain unique values.
  • Foreign Key (FK): A field in one table that references the Primary Key of another table to link them.
  • Composite Key: A primary key formed by combining two or more fields together.
  • Field Properties:Field Size • Format • Validation Rule (e.g. >=0 AND <=100) • Validation Text • Required • Default Value
5.4

ER Modeling & Normalization

Relationships: 1-to-1 (1:1), 1-to-Many (1:N), Many-to-Many (M:N - requires a junction table).

1NF (First Normal Form): All attributes are atomic (no repeating groups or multi-valued fields).

2NF (Second Normal Form): In 1NF + eliminate partial functional dependencies on composite keys.

3NF (Third Normal Form): In 2NF + eliminate transitive dependencies (non-key fields depending on other non-key fields).

5.5

Data Manipulation & Integrity

  • CRUD Operations: Create (Insert), Read (Select), Update, Delete.
  • Referential Integrity: A system rule enforcing that a Foreign Key value must either match an existing Primary Key value in the parent table or be Null.
  • Cascade Operations:
    • • Cascade Update: Updating a PK automatically updates all matching FK records.
    • • Cascade Delete: Deleting a PK parent record automatically deletes corresponding child FK records to prevent "orphan records".
5.6

Query Criteria & Design Grid

  • Query Design Grid Elements: Field, Table, Sort (Ascending/Descending), Show (checkbox), Criteria, Or.
  • Common Operators: AND, OR, NOT, BETWEEN x AND y, IN ("A", "B").
  • Wildcard Characters:
    • • LIKE "A*" matches any string starting with 'A'.
    • • LIKE "C?T" matches CAT, COT, CUT.
  • Parameter Query: Encloses a prompt in square brackets (e.g. [Enter City:]) to request criteria at runtime.
5.7

Aggregate Functions & Calculated Fields

⚡ Total Row & Grouping

Using the Group By clause aggregates records sharing identical category values.

Functions: SUM(), AVG(), COUNT(), MAX(), MIN()

🧮 Calculated Fields

Computes new values dynamically during query execution without storing them permanently in tables.

Syntax: TotalPrice: [Quantity] * [UnitPrice]

CHAPTER 5 INTERACTIVE CHALLENGE

🗄️ SQL & Query Architect Quest

SCORE: 0
LEVEL: 1/4
TABLE: Students

🔑 StudentID (PK)

Name

Class

TABLE: Enrollments

🔑 EnrollmentID (PK)

🔗 StudentID (FK)

Score

Loading database challenge...