Unit 5 Session 2: File Systems vs Models | IT 231 Slides

--:-- --
↓ Scroll for more

Unit 5 · Session 2

File Systems vs Models

IT 231: IT and Application (BBM)

Learning Objectives 🎯

By the end of this chapter, you will be able to:

  • ✅ Describe the traditional file system approach to managing data.
  • ✅ Identify the major problems (redundancy, inconsistency, isolation) of the file system approach.
  • ✅ Explain how the database approach solves these problems.
  • ✅ Define a database model and describe the hierarchical and network models.
  • ✅ Explain the structure of the relational model and why it is the modern standard.

The "Old Way": The File System Approach

Definition: Storing data in a collection of separate, application-specific files.

Think of it like separate digital filing cabinets for each department. 🗄️

  • The accounting department has its own set of files.
  • The sales department has a completely separate set of files.
  • Each application has its own private data.

Every department, its own boxes

An archive storage room with tall movable shelves full of boxed paper files at the US National Archives

Visualizing the File System Approach

The same customer data is duplicated across departments.

Accounting Dept.


customer_billing.csv

Contains: Name, Address, Bill

Sales Dept.


customer_contacts.txt

Contains: Name, Address, Phone

Marketing Dept.


mailing_list.xls

Contains: Name, Address, Email

🔍 This separation created several major problems for organizations.

Problem 1: Data Redundancy

The same piece of information is stored in multiple places unnecessarily.

Example: A customer's address is stored in:

  • The Sales file
  • The Marketing file
  • The Accounting file

Wasted Space & Effort

This wastes storage and requires multiple updates for a single change, leading to the next problem...

🧮 Worked Example: The Cost of Redundancy

A shop keeps each customer's address in 3 files: Sales, Marketing and Accounting.

File system

  • 5,000 customers; 500 move house each year
  • 500 moves × 3 files = 1,500 updates
  • Miss just 2% of them = 30 wrong addresses

Database

  • The address is stored once
  • 500 moves × 1 = 500 updates
  • Every department sees the change at once

Redundancy triples the work, and every extra copy is another chance for an error.

Problem 2: Data Inconsistency

A direct result of redundancy. When data is not updated everywhere, it becomes inconsistent and unreliable.

Scenario: Customer Moves

A customer, Sita Rai, moves from Pokhara to Kathmandu.

  • Sales updates their file: Address = Kathmandu ✅
  • Accounting forgets to update: Address = Pokhara ❌

Result: Which address is correct? The data cannot be trusted!

Problem 3: Data Isolation

Data is scattered in different files with different formats, making it difficult to access and integrate.

Sales Data

Format: .xls

Accounting Data

Format: .dat

Marketing Data

Format: .csv

Challenge: How do you write one program to get a complete, 360-degree view of a customer?

🔗 Problem 4: Program–Data Dependence

In a file system, each program has the file's layout written inside its code.

Scenario: The College Adds an Email Field

  • The student file changes from 4 fields to 5.
  • The fee, exam and hostel programs all read that file, so all three must be rewritten and re-tested.

Database fix: data independence. The DBMS stores the structure (metadata) separately, so a new column can be added without breaking programs that don't use it.

🧪 Activity: Name That Problem

Is it redundancy, inconsistency or isolation?

1. A hospital stores each patient's phone number in reception, lab and billing files. → Redundancy

2. Your bank statement shows your old address, but the mobile app shows the new one. → Inconsistency

3. A manager can't combine the sales Excel sheet with the accounting software's report. → Isolation

4. The college keeps your name in the library, exam and hostel files, and the hostel spells it "Bikas" instead of "Bikash". → Redundancy that led to inconsistency

The Solution: A New Approach ⚡

Organizations needed a way to manage data that was centralized, consistent, and accessible.

Enter the Database Approach.

The Database Approach

The solution is to store all organizational data in a single, centralized location, managed by a specific software.

Database: A shared collection of logically related data.

Database Management System (DBMS): Software that controls the creation, maintenance, and use of a database (e.g., MySQL, Oracle, SQL Server).

File System vs. Database Approach

Before: File System

Sales File

Acct. File

Mktg. File

...leads to...

Redundancy & Inconsistency

After: Database

Sales App

Acct. App

Mktg. App

...all access...

📊 Central Database (via DBMS)

The database provides a "single source of truth" for the entire organization.

Practical Application: Nepal Context

Scenario: Vehicle Registration ("Yatayat")

Imagine the old file-based system for vehicle ownership (the "blue book").

  • Traffic Police Office: Has a file for fines and violations.
  • Transport Management Office (Yatayat): Has a file for ownership and tax records.
  • Insurance Company: Has a file for the insurance policy.

Practical Application: Nepal Context (cont.)

Problem: If you sell your scooter, the new owner's name might be updated at the Yatayat office but not in the Traffic Police's file. A traffic fine could be sent to you, the old owner! This is data inconsistency.

Solution: A modern, centralized database ensures all three departments see the same, up-to-date owner information from a single source.

One vehicle, many offices' files

A Nepali vehicle number plate written in Devanagari script

Key Takeaways

  • The File System Approach stores data in separate, isolated files, leading to major problems.
  • The three core problems are Data Redundancy, Data Inconsistency, and Data Isolation.
  • The Database Approach solves this with a central database and a DBMS — a "single source of truth" that is consistent, secure, and shareable.
  • A database model is the logical blueprint of a database.
  • Early models like Hierarchical (tree) and Network (graph) were influential but rigid and complex.
  • The Relational Model is the modern standard, using simple, flexible tables queried with SQL.

Exam Practice: Short Answer

  1. Define data redundancy and data inconsistency.
  2. What is data isolation?
  3. What is program–data dependence?
  4. What is a database model? Name four models.
  5. Differentiate between a primary key and a foreign key.
  6. What is NoSQL?

Exam Practice: Long Answer

  1. Explain the limitations of the file system approach. How does the database approach overcome them?
  2. Compare the file system and database approaches with a suitable example.
  3. Explain the hierarchical, network, and relational models with diagrams.
  4. Describe the relational model with an example of two related tables. Why is it the most popular model?

Revise the Database vs. File System and Database Models notes before writing these answers.

What is a Database Model?

A database model is a set of rules and standards that defines the logical structure of a database.

It determines how data is stored, organized, and manipulated.

Think of it as the blueprint for a database. 📐

A Look Back: Early Database Models

Before the modern relational model became standard, data was organized differently. Let's explore two influential early models.

1. Hierarchical Model

2. Network Model

1. The Hierarchical Model 🌳

This model organizes data in a rigid, tree-like structure.

Key Features

  • Data is structured like an organization chart.
  • There is a single "root" at the top.
  • Each "child" record has only one parent.

Major Disadvantage

  • Very inflexible.
  • To access data, you must start at the root and navigate down the tree.

The Hierarchical Model: One Parent per Record

Tree diagram: each record type has one parent and can have many children

2. The Network Model 🕸️

An evolution of the hierarchical model, offering more flexibility.

Key Features

  • Data is in a graph-like structure.
  • A "child" record can have multiple parent records.
  • This allows for more complex relationships.

Major Disadvantage

  • While more flexible, it was still very complex to navigate and manage.

The Network Model: Many Owners Allowed

Network diagram: record types linked so that one record can have several owners

The Game Changer: Relational Model ⚡

Developed by E.F. Codd in 1970, this model revolutionized how we think about data.

The relational model is the basis for almost all modern database systems we use today, including MySQL, PostgreSQL, and SQL Server.

🌍 Real Story: One Paper That Changed Computing

  • 1970: IBM researcher Edgar F. Codd published "A Relational Model of Data for Large Shared Data Banks".
  • IBM was slow to sell it, because its profitable hierarchical product (IMS) was already selling well.
  • IBM's research project System R created the query language that became SQL.
  • A young programmer named Larry Ellison read the research, and his company released Oracle in 1979, one of the first commercial SQL databases.

Lesson: The best idea doesn't always win for the company that invented it. Oracle is still one of the largest database companies today.

🎬 Tables, Rows and Columns

How the Relational Model Works 📊

It organizes data into simple, two-dimensional tables (also called relations).

Tables

Store data about a specific entity (e.g., `Students`, `Courses`).

Rows (Records)

Represent a single instance of that entity (e.g., one specific student).

Columns (Fields)

Represent an attribute of that entity (e.g., `FirstName`, `CourseID`).

Visualizing Relational Tables

Imagine a simple database for our university.

Table: `Students`


| StudentID | FirstName | LastName |
|-----------|-----------|----------|
| 101       | Anjali    | Thapa    |
| 102       | Bikash    | Shrestha |
    

Table: `Enrollments`


| EnrollmentID | StudentID | CourseID |
|--------------|-----------|----------|
| 1            | 101       | IT231    |
| 2            | 102       | IT231    |
    

Tables are linked together using common fields called keys (like `StudentID`).

🔑 Primary Keys and Foreign Keys

Primary key (PK)

It uniquely identifies each row in its own table.

StudentID in Students, where 101 = Anjali and 102 = Bikash.

Foreign key (FK)

It's a field that points to the primary key of another table.

StudentID in Enrollments says which student took IT231.

  • Rule: a foreign key value must already exist as a primary key. You can't enrol student 999 if there's no student 999.
  • This is called referential integrity, and the DBMS enforces it automatically.

🎬 Primary and Foreign Keys

🧮 Worked Example: Design the Tables for a College Library

Step 1, entities: Member, Book, Loan

Step 2, attributes and keys:

Members(MemberID PK, Name, Programme)

Books(BookID PK, Title, Author)

Loans(LoanID PK, MemberID FK, BookID FK, IssueDate, DueDate)

Step 3, relationships: one member has many loans; one book has many loans over time (both one-to-many).

In an ER diagram: Member 1 ──< Loan >── 1 Book. The Loans table links the other two through its foreign keys.

🧪 Activity: One-to-One, One-to-Many or Many-to-Many?

1. A citizen and their citizenship certificate → One-to-one

2. A customer and their orders → One-to-many

3. A bank branch and its staff → One-to-many

4. Students and courses → Many-to-many

5. Authors and books → Many-to-many (one book can have several authors)

Rule: a many-to-many link needs a linking table, like Enrollments between Students and Courses.

🧪 Activity: Spot the Keys in a Hospital Database

Patients(PatientID, Name, Phone)

Doctors(DoctorID, Name, Department)

Appointments(AppointmentID, PatientID, DoctorID, Date)

1. Primary key of each table? → PatientID, DoctorID, AppointmentID

2. Foreign keys? → PatientID and DoctorID in Appointments

3. Can we book an appointment with DoctorID 77 if there is no doctor 77? → No: referential integrity blocks it.

What Real Relational Tables Look Like

An entity-relationship diagram: boxes for tables with their fields, connected by lines that show key links

Accessing the Data: SQL 🔍

The power of the relational model is unlocked with a special language.

SQL (Structured Query Language) is the standard language for managing and querying data in relational databases.

It allows for powerful, flexible, and easy-to-understand data manipulation.


SELECT FirstName FROM Students WHERE StudentID = 101;
-- Result: Anjali
  

🧪 Activity: What Will This Query Return?

Use the Students and Enrollments tables from the earlier slide.

1. SELECT LastName FROM Students WHERE FirstName = 'Bikash'; → Shrestha

2. SELECT COUNT(*) FROM Enrollments WHERE CourseID = 'IT231'; → 2

3. SELECT FirstName FROM Students WHERE StudentID = 103; → no rows, because there is no student 103

4. Write it yourself: list everyone's first name. → SELECT FirstName FROM Students;

🧱 Beyond Tables: Object-Oriented and NoSQL Models

Object-Oriented Model

Stores data as objects that hold both data (attributes) and actions (methods), like objects in Java or Python.

Suits complex items: engineering designs, maps, multimedia.

NoSQL ("Not only SQL")

Drops fixed tables for flexible formats: documents (MongoDB), key–value (Redis), graphs (Neo4j).

Suits huge, fast-changing data: social feeds, product catalogues.

Exam tip, the four classic models: hierarchical, network, relational, object-oriented. For money and exam records, relational is still the standard.

🌍 Real Case: Discord's Trillions of Messages

  • The chat app Discord stores every message in a wide-column NoSQL database, another NoSQL family. Data is spread across many servers ("nodes").
  • 2017: 12 Cassandra nodes held billions of messages. Early 2022: 177 nodes held trillions.
  • Discord then moved everything to ScyllaDB, a faster Cassandra-compatible database (its 2023 engineering blog): 72 nodes instead of 177, and the slowest 1% of reads fell from 40–125 ms to about 15 ms.

Lesson: NoSQL shines for huge, simple, fast-growing data like chat messages, which is spread over many machines.

Practical Application in Nepal

Relational databases power many systems we use daily.

Digital Wallets (eSewa, Khalti)

They use tables for `Users`, `Transactions`, and `Merchants`. Your transaction history is linked to your User ID, which is a key in the `Transactions` table.

Government Services (Nagarik App)

Integrates data from different government bodies. It likely has tables for `Citizens`, `Documents` (like citizenship, PAN), and `Services`, all linked by a unique Citizen ID.

🧪 Activity: Which Model Fits Best?

Hierarchical, network or relational?

1. Your computer's folders: C: → Users → Documents → IT231 → Hierarchical (every folder has one parent)

2. Airline routes: Kathmandu links to Pokhara, Delhi and Dubai, and each of those links to many more cities → Network (many-to-many links)

3. A bank's customers, accounts and transactions → Relational (tables linked by keys)

4. A company organisation chart → Hierarchical

5. Facebook friends → Network/graph

💬 Discussion Questions

  1. Give one example of data redundancy you've seen at your college, a bank or a government office. What went wrong?
  2. If the relational model is so good, why do some companies still use older systems, or very different ones such as NoSQL?
  3. The Nagarik App links data from many offices. What new risks come from putting everything in one place?

Image & Video Credits

Images

  • "NARA Backstage Pass (2011-08) - 04.jpg" (archive storage stacks): Jarek Tuszyński, CC BY-SA 3.0, via Wikimedia Commons
  • "Devanagari Vehicle Number plate.jpg": Innocentbunny, CC BY-SA 3.0, via Wikimedia Commons
  • "Hierarchical Model.svg": U.S. Department of Transportation (vectorised by Razorbliss), Public domain, via Wikimedia Commons
  • "Network Model.svg": U.S. Department of Transportation (vectorised by Razorbliss), Public domain, via Wikimedia Commons
  • "Entity-relationship-diagram-luna-modeler.png": Vasek Frolik, CC BY 4.0, via Wikimedia Commons

Videos (YouTube)

  • IBM Technology, "What is a Relational Database?" (0:51–2:16), https://www.youtube.com/watch?v=OqjJjpjDRLc
  • CockroachDB, "What is a Foreign Key Constraint? Understanding Primary & Foreign Keys" (1:02–2:29), https://www.youtube.com/watch?v=5kiMg7GXAsY

Teaching content © Arjan KC. Third-party media remain the property of their owners.

Thank You!

Any Questions?

📖 Read first (chapter notes)