Create entity relationship diagrams (conceptual, logical)
10 Database and File Concepts
📚 What is a Database?
A database is like a super‑organized library where every book (record) is stored in a specific shelf (table). The library keeps a catalog (schema) so you can quickly find any book without searching the whole building.
Key terms:
- Table – a collection of related records.
- Record (Row) – a single data entry.
- Field (Column) – a specific attribute of a record.
- Primary Key – a unique identifier for each record.
📁 File Concepts
Think of a file as a single drawer in a filing cabinet. Inside the drawer are folders (sub‑files) that hold documents (data). Files are stored on a disk and can be:
- Flat files – simple text or CSV files, no relationships.
- Hierarchical files – folders nested inside folders.
- Relational files – tables linked by keys (like a database).
Unlike databases, files don’t enforce data integrity automatically – you must handle duplicates, missing values, and relationships yourself.
🗂️ Entity‑Relationship Modelling
ER modelling is the blueprint for a database. It shows entities (things we care about) and relationships (how they interact).
Conceptual ERD
High‑level view – no technical details, just the main entities.
- Identify entities (e.g., Student, Course).
- Define attributes for each entity.
- Determine primary keys.
- Sketch relationships (one‑to‑many, many‑to‑many).
Logical ERD
Adds structure: data types, constraints, and normalisation.
- Convert conceptual entities to tables.
- Specify data types (INT, VARCHAR, DATE).
- Add foreign keys to represent relationships.
- Apply normalisation rules (1NF, 2NF, 3NF).
Example: A Student can enrol in many Courses, and a Course can have many Students – a many‑to‑many relationship resolved by an Enrolment table.
🔗 Relationships and Cardinality
Cardinality tells how many instances of one entity relate to another:
| Relationship | Notation | Example |
|---|---|---|
| One‑to‑Many | $1 \leq n \leq \infty$ | One Teacher teaches many Students. |
| Many‑to‑Many | $1 \leq n \leq \infty$ on both sides | Students enrol in many Courses; Courses have many Students. |
| One‑to‑One | $1 = 1$ | Each Student has one StudentID. |
🏗️ Normalisation Basics
Normalisation removes redundancy and improves data integrity.
- 1NF – No repeating groups; each field contains atomic values.
- 2NF – All non‑key attributes fully depend on the primary key.
- 3NF – No transitive dependencies; non‑key attributes depend only on the key.
Analogy: Think of normalisation as cleaning your room – you put each item in its proper place so you can find it easily and avoid clutter.
📌 Quick Reference Cheat Sheet
| Concept | Key Point |
|---|---|
| Primary Key | Unique, not null, immutable. |
| Foreign Key | References a primary key in another table. |
| Many‑to‑Many | Solved with a junction table. |
| Normalisation | Reduces data duplication. |
Revision
Log in to practice.