Chapter 5: Relational Database
Relational Database Systems (RDBMS)
Databases provide structured, multi-user storage with strict data integrity, normalized table relationships, automated SQL querying, and zero data redundancy.

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.
Database Objects
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
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).
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".
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.
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]
🗄️ SQL & Query Architect Quest
🔑 StudentID (PK)
Name
Class
🔑 EnrollmentID (PK)
🔗 StudentID (FK)
Score
Loading database challenge...