Learning Objectives
By the end of this chapter, you will be able to:
- Define the database approach and the DBMS as its gatekeeper.
- Explain the five advantages of the database approach against file based failures.
- Describe tables, rows, columns, primary keys, and foreign keys in the relational model.
- Read a small ERD and translate it into tables that enforce a single source of truth.
From Scattered Files To A Single Truth
The database approach replaces many owned files with one shared collection of related data under one rule set. Applications do not go to files directly. They go through a Database Management System that enforces structure, integrity, security, and concurrency.
flowchart TB
SALES["Sales"] & ACCT["Accounting"] & MKT["Marketing"] <--> DBMS["DBMS\nRules, access, recovery"] <--> DB[("Database\nSingle source of truth")]
style DB fill:#1565c0,color:#fff
Figure 1: Shared database mediated by a DBMS
| Concept | What it is | Example |
|---|---|---|
| Database | Related data stored with defined structure and relationships | One member master shared by counter and reports |
| DBMS | Software that creates, protects, and controls access | MySQL, PostgreSQL, Oracle, SQL Server that enforces keys and roles |
Why The Database Approach Wins
1. Minimized redundancy and inconsistency. A fact such as address is stored once and referenced elsewhere. Change once, read everywhere. 2. Integration and sharing. One definition lets queries join sales with accounting without manual stitching. 3. Security and controlled access. The DBMS grants read, insert, update, delete per user and object. 4. Standards and integrity. Rules such as phone pattern or quantity greater than 0 are rejected at entry. 5. Concurrency, recovery, and audit. Many users work at once with locking and transactions, and every change can be logged.
The Relational Model
Most syllabus systems are relational. Data sits in tables. Tables relate through keys.
| Component | Meaning | Exam cue |
|---|---|---|
| Table | All records of one entity type | STUDENT, PRODUCT |
| Row | One entity instance | One student, one invoice |
| Column | One property | Address, Price |
| Primary key | Uniquely identifies each row | StudentID, never duplicated |
| Foreign key | Copy of a primary key placed in another table to link | StudentID in ENROLLMENT points to STUDENT |
| Constraint | Rule enforced by DBMS | Email unique, grade from a list |
Relationships: one to many needs a foreign key on the many side. Many to many cannot be stored directly and needs a linking table such as ENROLLMENT that holds both foreign keys plus attributes of the link.
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ ORDER_ITEM : contains
PRODUCT ||--o{ ORDER_ITEM : "is in"
CUSTOMER { int CustomerID PK string Name }
ORDER { int OrderID PK int CustomerID FK }
PRODUCT { int ProductID PK string ProductName }
ORDER_ITEM { int OrderID FK int ProductID FK int Quantity }
Figure 2: Keys that enforce relationships
Design Before Build
An ERD is a design drawing. Entities, attributes, and cardinality are set before tables are built. Normalization to third normal form, where each non key attribute depends on the key and nothing but the key, removes remaining redundancy that naive tables leave.
Worked Example: One College, One Database, BS 2081
The college replaces four spreadsheets with one database in BS 2081.
STUDENT
| StudentID PK | Name | Address |
|---|---|---|
| S101 | Sita Sharma | Bhaktapur |
| S102 | Ram Thapa | Lalitpur |
COURSE
| CourseID PK | Title | Credits |
|---|---|---|
| IT233 | Business Information Systems | 3 |
| IT204 | E-Commerce | 3 |
ENROLLMENT
| StudentID FK | CourseID FK | Semester | Grade |
|---|---|---|---|
| S101 | IT233 | 3 | A |
| S101 | IT204 | 3 | B+ |
| S102 | IT233 | 3 | A- |
Rules enforced: address lives only in STUDENT, primary keys prevent duplicates, foreign keys prevent orphan enrollments, and a check allows only listed grades. If file based divergence cost Rs. 10,800 per term as estimated earlier, the single table removes about Rs. 32,400 per year in correction.
Self-Check Sketch ENROLLMENT with its two foreign keys and state why the many to many between STUDENT and COURSE needs that linking table. Then name one constraint that would stop a wrong grade.
Try This The design costs Rs. 195,000 to build and Rs. 7,500 per month to run. It saves 28 staff hours per month versus manual stitching at Rs. 550 per hour and avoids Rs. 10,800 per term in correction, with 3 terms per year. Compute monthly gross saving, net saving, and payback.
Answers: Labour 28 times 550 equals Rs. 15,400. Correction per month 32,400 divided by 12 equals Rs. 2,700. Gross Rs. 18,100. Net 18,100 minus 7,500 equals Rs. 10,600. Payback 195,000 divided by 10,600 equals 18.4 months, so month 19.
Summary
The database approach stores related data once under a DBMS that enforces definition, integrity, security, and recovery, producing a single source of truth. The relational model implements this through tables, keys, and constraints, with ERDs to design relationships before build.
Key Takeaways
- The DBMS is the gatekeeper. No application touches data except through rules.
- Store a fact once and reference it by key.
- Primary keys identify, foreign keys link, constraints protect.
- Many to many needs a linking table.
- ERD quality determines report quality later.
Discussion Questions
- A firm moves files to a shared drive and calls it a database. Which advantage still fails?
- Two customers share the same phone. Should the phone be unique and how does that affect reporting?
- Why does a good ERD still need governance?
Exercises
Short answer
- Define DBMS and its three roles.
- Distinguish primary key from foreign key with one example from the college design.
- What is an ERD and what does it show?
- Name two advantages that fix file based failures.
Long answer
- Explain how the database approach solves redundancy, inconsistency, and isolation with the college case in BS 2081. Show how keys and constraints enforce the fix.
- Draw an ERD for Member, Savings Account, and Loan. Resolve the many to many, choose keys, and state three constraints.


