Create entity relationship diagrams (conceptual, logical)

Topic 10 – Database and File Concepts

Learning objectives

  • Design a relational database using Entity‑Relationship (ER) modelling.
  • Distinguish between conceptual and logical ER diagrams and map each element to the Cambridge AS/A‑Level IT 9626 syllabus.
  • Normalise a database up to Third Normal Form (3NF) and explain the advantages of each normal form.
  • Produce a complete data‑dictionary for the designed database.
  • Explain file‑management concepts, the main types of DBMS and their advantages/disadvantages.
  • Implement validation, verification and error‑checking mechanisms.
  • Design a data‑entry form, a switchboard/menu and basic reports.
  • Import and export data using common file formats (CSV, TXT, RTF).

1. Creating a database – overview (10.1)

  1. Gather requirements from users and stakeholders.
  2. Identify **entities**, **attributes**, **primary keys (PK)** and **foreign keys (FK)**.
  3. Define relationships, cardinalities and any integrity constraints.
  4. Draw a conceptual ER diagram – a high‑level business view.
  5. Refine to a logical ER diagram** – ready for implementation (includes all attributes, PK/FK notation and data‑type hints).
  6. Normalise the logical model to 3NF.
  7. Produce a data‑dictionary.
  8. Choose an appropriate DBMS and file‑management strategy.
  9. Design data‑entry forms, switchboard/menu and reports.
  10. Implement validation, verification and error‑checking.
  11. Import and export data (CSV, TXT, RTF).

2. Entity‑Relationship modelling

2.1 Conceptual ER diagram

  • Shows only the essential entities, primary keys and relationships.
  • Attributes are limited to those required to understand the business rules.
  • Notation (Cambridge‑recommended):
    • Rectangle = entity.
    • Diamond = relationship.
    • Lines with cardinality symbols (1, 0..1, 1..N, N) or crow‑foot notation.

2.2 Logical ER diagram

  • All attributes for each entity are listed inside the entity rectangle.
  • Primary keys are underlined; foreign keys are identified (FK).
  • Data types may be noted as a side comment (e.g., VARCHAR(30), INT).
  • Repeating groups, partial and transitive dependencies have been removed (i.e. the diagram is already normalised).

2.3 Referential integrity

Referential integrity guarantees that a foreign‑key value always matches an existing primary‑key value in the referenced table. It prevents orphan records and maintains consistency across related tables. In most relational DBMSs it is enforced by defining FK constraints (e.g., ON DELETE CASCADE or ON UPDATE RESTRICT).

2.4 Mapping ER‑diagram elements to the syllabus (10.1)

Syllabus sub‑point ER‑diagram element What to show
Entities & primary keys Entity rectangle + underlined attribute Student (PK StudentID), Course (PK CourseCode)…
Attributes List inside entity rectangle StudentName, DateOfBirth, Email…
Foreign keys FK attribute in a dependent entity Enrolment.StudentID (FK), Enrolment.CourseCode (FK)
Relationships & cardinality Diamond + crow‑foot notation Student 1..N ↔ 0..N Course (many‑to‑many resolved by Enrolment)
Normalization (1NF‑3NF) Logical diagram after removing repeating groups Separate Enrolment entity eliminates multi‑valued attribute “CoursesTaken”.

2.5 Example – University Course Management System

Conceptual ER diagram (suggested)

Entities: Student, Course, Enrolment. Cardinalities: Student 1..N ↔ Enrolment 0..N ↔ Course 1..N.

Logical ER diagram (suggested)

All attributes listed, PK underlined, FK marked, data‑type notes added.

3. Normalisation to Third Normal Form (10.2)

3.1 Why normalise?

  • Eliminate data redundancy.
  • Reduce update, insertion and deletion anomalies.
  • Make the database easier to maintain and extend.
  • Improve query performance when proper indexes are used.

3.2 Normalisation steps – worked example

Stage Structure (sample data) Key characteristics
Un‑normalised table (UNF)
StudentID | StudentName | CourseCodes               | Grades
-----------------------------------------------------------------
001       | Alice       | CS101, MA102              | A, B
002       | Bob         | CS101                     | B
Repeating group – multiple CourseCodes/Grades per student.
First Normal Form (1NF)
StudentID | StudentName | CourseCode | Grade
------------------------------------------------
001       | Alice       | CS101      | A
001       | Alice       | MA102      | B
002       | Bob         | CS101      | B
Atomic values only; each row contains a single value for every attribute.
Second Normal Form (2NF)
-- Student table
StudentID | StudentName
-------------------------
001       | Alice
002       | Bob

-- Enrolment table
EnrolmentID | StudentID | CourseCode | Grade
---------------------------------------------
E001        | 001       | CS101      | A
E002        | 001       | MA102      | B
E003        | 002       | CS101      | B
All non‑key attributes fully depend on the whole primary key (no partial dependencies).
Third Normal Form (3NF)
-- Student (PK = StudentID)
StudentID | StudentName | DateOfBirth | Email

-- Course (PK = CourseCode)
CourseCode | CourseTitle | Credits | Department

-- Enrolment (PK = EnrolmentID)
EnrolmentID | StudentID (FK) | CourseCode (FK) | EnrolDate | Grade
No transitive dependencies; every non‑key attribute describes only the primary key.

3.3 Quick normalisation checklist

  • 1NF – remove repeating groups; ensure each field holds an atomic value.
  • 2NF – eliminate partial dependencies (only relevant when the primary key is composite).
  • 3NF – eliminate transitive dependencies; each non‑key attribute must depend solely on the primary key.

4. Data‑dictionary (10.3)

4.1 Purpose

  • Provides a definitive description of every field in the database.
  • Facilitates clear communication between designers, developers and end‑users.
  • Supports validation, verification and documentation.

4.2 Standard template

Field name Data type & size Key (PK/FK) Allow null? Default value Description / validation rule
StudentID INT (4) PK No Auto‑number Unique identifier for each student.
StudentName VARCHAR (30) No Alphabetic characters only; max 30.
Email VARCHAR (50) Yes Must match pattern xxx@yyy.zzz.
CourseCode CHAR (6) PK No e.g. “CS101”.
EnrolmentID INT (4) PK No Auto‑number Unique identifier for each enrolment record.
Grade CHAR (2) Yes NULL Allowed values: A, B, C, D, F.

4.3 Mini‑exercise

Complete the data‑dictionary for the Course entity (add fields such as CourseTitle, Credits, Department). Submit the filled table for peer review.

5. File and data management (10.4)

5.1 Types of files

File type Access method Typical use in DBMS
Flat (sequential) file Sequential access Simple data import/export, log files.
Random‑access (indexed) file Direct access via index Primary storage for DBMS tables.
Relational file Direct access via primary/foreign keys Core of relational DBMS (e.g., Access, MySQL).

5.2 Management Information Systems (MIS)

  • Collects, stores and processes data to support decision‑making.
  • Relies on a well‑designed database for accurate reporting.
  • Typical MIS reports: student enrolment statistics, course popularity, grade distributions.

5.3 DBMS families – advantages & disadvantages

DBMS type Key characteristics Advantages Disadvantages
Hierarchical Tree‑like structure; parent‑child relationships. Fast navigation for predictable hierarchies. Rigid; difficult to model many‑to‑many relationships.
Network Graph structure; multiple parent nodes. Efficient for complex relationships. Complex to design and maintain; less intuitive.
Relational Tables with primary/foreign keys; uses SQL. Highly flexible; strong theoretical foundation; wide tool support. Performance can degrade with very large tables without proper indexing.
Object‑oriented Stores objects, supports inheritance. Ideal for applications using OO programming languages. Less mature query language; fewer commercial products.

5.4 Indexing and access methods

  • Primary‑key index: automatically created; enables fast direct look‑up.
  • Secondary (non‑unique) index: created on frequently searched fields (e.g., Email, Grade).
  • Choosing the right index reduces query time but adds overhead on insert/update operations.

6. Validation, verification and error‑checking (10.1 & 10.4)

6.1 Common validation rules

  • Domain constraints – e.g., Grade must be one of {A,B,C,D,F}.
  • Format checks – e.g., Email must contain “@” and a domain.
  • Range checks – e.g., Credits between 1 and 10.
  • Uniqueness – primary‑key and candidate‑key enforcement.
  • Referential integrity – foreign‑key values must exist in the referenced table.

6.2 Implementation checklist (Microsoft Access / LibreOffice Base)

  1. Open the table in **Design view**.
  2. Set the **Data Type** and **Field Size** for each attribute.
  3. Mark the primary key (right‑click → **Primary Key**).
  4. For foreign keys, choose **Lookup Wizard** or set a **Relationship** in the Relationships window.
  5. Define **validation rules** (e.g., Between 1 And 10 for Credits).
  6. Set **Required** = Yes for fields that cannot be left blank.
  7. Enable **Referential Integrity** in the Relationships window (check “Enforce Referential Integrity”).
  8. Save the table and test by entering sample data.

7. Designing data‑entry forms (10.1)

7.1 Form design checklist

  • Layout – group related fields together; use tabs or sections.
  • Tab order – set a logical sequence for keyboard navigation.
  • Required fields – mark with an asterisk and set the **Required** property.
  • Control types – use text boxes for free text, combo boxes or list boxes for limited choices, date pickers for dates.
  • Default values – pre‑populate fields where appropriate (e.g., current date for EnrolDate).
  • Error messages – customise the **Validation Text** property to give clear feedback.
  • Navigation buttons – include **Next**, **Previous**, **New Record**, **Save**, **Delete**.
  • Form caption – clearly state the purpose (e.g., “Student Registration Form”).

8. Switchboard / menu design (10.1)

A switchboard provides a single point of entry to the database’s forms, reports and queries.

  • In Access: File → New → Blank Database → Switchboard Manager.
  • In LibreOffice Base: create a **Main Form** with command buttons linked to other forms/reports.
  • Design tips:
    • Group actions logically (e.g., “Data Entry”, “Reports”, “Maintenance”).
    • Use clear button labels (“Add Student”, “View Enrolments”).
    • Include an **Exit** button that closes the application.
    • Apply a consistent colour scheme and font for a professional look.

9. Importing and exporting data (10.1 & 10.4)

9.1 Importing CSV/TXT files

  1. In Access: External Data → New Data Source → From File → Text File.
  2. In Base: File → New → Database → Connect to Existing Database → Text.
  3. Choose the source file (CSV or TXT).
  4. Select **First Row Contains Field Names** if applicable.
  5. Specify the delimiter (comma for CSV, tab for TXT).
  6. Map each source column to the appropriate table field; adjust data types if needed.
  7. Run the import and verify the data in the target table.

9.2 Exporting to CSV/TXT/RTF

  1. Open the table or query you wish to export.
  2. In Access: External Data → Export → Text File. In Base: File → Export → Text.
  3. Choose the destination folder and file name (e.g., Students.csv).
  4. Select the appropriate format:
    • CSV – comma‑separated values.
    • TXT – tab‑delimited or fixed‑width.
    • RTF – for formatted reports (use the Report wizard, then export).
  5. Check “Include Field Names on First Row” if required.
  6. Complete the wizard and open the exported file to confirm correct formatting.

10. Summary checklist for Cambridge 9626 (10.1‑10.4)

  • Identify entities, attributes, PKs and FKs.
  • Draw conceptual and logical ER diagrams (with correct notation).
  • Explain and enforce referential integrity.
  • Normalise to 3NF and justify each step.
  • Create a complete data‑dictionary.
  • Design a functional data‑entry form and a switchboard/menu.
  • Define validation, verification and error‑checking rules.
  • Choose appropriate file types and DBMS; discuss advantages/disadvantages.
  • Demonstrate import and export of CSV, TXT and RTF files.

Create an account or Login to take a Quiz

41 views
0 improvement suggestions

Log in to suggest improvements to this note.