How DBMS Manages Concurrent Data Access and Solves Data Access Problems Compared to File Systems

 

How DBMS Manages Concurrent Access of Data and Data Access Difficulties over File System

A Database Management System (DBMS) is designed to overcome major limitations of a traditional file system, especially in handling concurrent access of data and data access difficulties. These problems are critical in multi-user environments where data consistency, correctness, and easy retrieval are required.


1. Concurrent Access of Data

1.1 Problem in File System

In a file system, multiple users can access and modify the same file simultaneously without proper control. This may cause lost updates, inconsistency, and data corruption.

Scenario (File System)

Consider a bank account stored in a file:

Account No: 101 Balance: 10000

Two users access the file at the same time:

  • User A deposits 2000

  • User B withdraws 1000

Execution Steps

  1. User A reads balance = 10000

  2. User B reads balance = 10000

  3. User A writes balance = 12000

  4. User B writes balance = 9000

Final balance = 9000 (incorrect)
✔ Correct balance should be 11000

Reasons

  • No transaction concept

  • No locking mechanism

  • No rollback or recovery support


1.2 How DBMS Solves Concurrent Access

A DBMS controls concurrent access using:

  • Transactions

  • Locks (Shared & Exclusive)

  • Concurrency control protocols

  • Isolation levels


DBMS Example with SQL

Table Creation

CREATE TABLE Account ( account_no INT PRIMARY KEY, balance DECIMAL(10,2) ); INSERT INTO Account VALUES (101, 10000);

Transaction – User A (Deposit 2000)

BEGIN TRANSACTION; UPDATE Account SET balance = balance + 2000 WHERE account_no = 101; COMMIT;

Transaction – User B (Withdraw 1000)

BEGIN TRANSACTION; UPDATE Account SET balance = balance - 1000 WHERE account_no = 101; COMMIT;

How DBMS Ensures Correctness

  • DBMS applies an exclusive lock on the account row

  • Second transaction waits until the first completes

  • Transactions execute in a serializable manner

Final balance = 11000 (correct)
✔ Data consistency is preserved


2. Data Access Difficulties

2.1 Problem in File System

File systems suffer from several data access issues:

  • Data redundancy

  • Poor data sharing

  • Complex program logic

  • No data independence

Scenario (File System)

Student data stored in multiple files:

  • student_info.txt

  • student_marks.txt

  • student_attendance.txt

To retrieve complete information of a student:

  • Programmer must read multiple files

  • Write complex procedural code

  • Any change in file structure requires program modification

❌ Difficult maintenance
❌ Low flexibility


2.2 How DBMS Solves Data Access Difficulties

DBMS organizes data using tables, schemas, relationships, and SQL, providing:

  • Logical & physical data independence

  • Simple and flexible data retrieval

  • Centralized data control


DBMS Example with SQL

Table Design

CREATE TABLE Student ( student_id INT PRIMARY KEY, name VARCHAR(50), department VARCHAR(30) ); CREATE TABLE Marks ( student_id INT, cgpa DECIMAL(3,2), FOREIGN KEY (student_id) REFERENCES Student(student_id) ); CREATE TABLE Attendance ( student_id INT, attendance_percent DECIMAL(5,2), FOREIGN KEY (student_id) REFERENCES Student(student_id) );

Insert Sample Data

INSERT INTO Student VALUES (1, 'Rahim', 'CSE'); INSERT INTO Marks VALUES (1, 3.75); INSERT INTO Attendance VALUES (1, 92.5);

Easy Data Retrieval Using SQL

SELECT s.name, s.department, m.cgpa, a.attendance_percent FROM Student s JOIN Marks m ON s.student_id = m.student_id JOIN Attendance a ON s.student_id = a.student_id;

✔ Single query retrieves all data
✔ No complex programming
✔ High data sharing and flexibility


3. Comparison Summary

FeatureFile SystemDBMS
Concurrent AccessNot controlledControlled via locks & transactions
Data ConsistencyNot guaranteedGuaranteed (ACID)
Data AccessProgram dependentSQL based
Data RedundancyHighMinimal
Data IndependenceNot supportedSupported

Conclusion

A DBMS effectively manages concurrent access using transactions and locking mechanisms, ensuring data consistency even in multi-user environments. It also resolves data access difficulties by providing structured storage, SQL-based retrieval, and data independence. Compared to file systems, DBMS offers better reliability, scalability, and ease of data management, making it the preferred choice for modern applications.

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন