DBMS Core Series: 1.1
Introduction
Databases power our digital world, and at the heart of managing them efficiently is the Database Management System (DBMS). In this blog, we’ll break down essential DBMS concepts and common challenges that every developer should know.
Basics Terms
Data
Information
Database
DBMS (Database Management System)
In summary all these terms can be summed up into one line as
Data: Raw facts (e.g., "35°C").
Information: Processed data with context (e.g., "Temperature in Nagpur is 35°C").
Database: Organized data storage.
DBMS: Software managing and interacting with databases.
Understanding File Systems & Transactions
Problems with File Systems
Data Redundancy and Inconsistency: In file systems, the same data can be duplicated across different files. For example, if an employee's contact information is stored in two different spreadsheets, one file could be updated while the other remains outdated, leading to confusion about the correct information.
Difficulty in Accessing Data: Retrieving specific data from file systems often requires assistance from IT specialists or complex programming, making it time-consuming. For instance, you may need to wait for an IT team to generate a report that could be easily retrieved in a DBMS
Data Isolation: In file systems, data might be stored in various formats or locations, making it difficult to combine information. For example, customer profiles may be stored in one system while order histories are stored in another, making it hard to view a comprehensive customer profile.
Integrity Problems: Integrity issues arise when data is updated in one location but not in another. For example, if a customer changes their address on a website, and this update is not reflected throughout all systems, old addresses may still appear in some areas.
Atomicity Problems: A file system might only partially execute operations. For instance, in a banking transaction, money might be deducted from one account but not credited to another due to a failure, resulting in an incomplete transaction.
Concurrent Access Anomalies: File systems can encounter issues when multiple users try to access and update data simultaneously. For example, two users trying to book the last ticket for a flight at the same time might both get confirmation, even though only one seat is available.
Transactions in DBMS
Why We Study Transactions
According to the general computation principle (operating system), we may have a partially executed program, as the level of atomicity is instruction i.e. either an instruction is executed completely or not . But in the DBMS view, the user performs a logical work(operation) which is always atomic i.e. either operation is executed or not executed, there is no concept like partial execution.
What is a Transaction?
A transaction is a bundle of logically related instructions that perform a single logical unit of work. In DBMS, it includes two basic operations:
READ (X): Accessing data from the database.
WRITE (X): Writing data back to the database after modifications.
For example, consider the following transaction for transferring 100 units from Account A to Account B:
T1:
Read(A)
A = A - 100
Write(A)
Read(B)
B = B + 100
Write(B)
In this transaction, the database ensures that both accounts remain balanced and consistent after the transaction, preventing partial execution from corrupting the data.
Transaction States
A transaction passes through various states during its execution:
Active: The transaction is in progress and performing operations.
Partially Committed: The transaction has completed its operations, but changes are still in memory and may be lost if not written to disk.
Failed: The transaction encounters an error or issue and cannot proceed.
Aborted: The transaction is rolled back, restoring the database to its previous state before the transaction began.
Committed: The transaction completes, and its changes are permanently stored in the database.
Conclusion
Subscribe to my newsletter
Read articles from Dev Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by