Database
A database is a systematic and organized collection of related data that can be easily accessed,
managed, and updated using a computer system.
It helps users store large amounts of data efficiently and retrieve it quickly using queries.
The data is usually organized in tables, with rows and columns similar to a spread sheet.
Example: College Database System:
Think of a college where we need to store student information.
We can create a database named CollegeDB, and it will contain tables like:
Table: Student
RollNo Name Department Marks
101 Amit CSE 89
102 Sneha ENTC 92
103 Rahul Civil 75
----------------------------------------------------------------------------------------------------------------
Database Management System (DBMS)
A Database Management System (DBMS) is software that allows users to create, manage, store,
retrieve, and update data in a database efficiently and securely.
It acts as a bridge between the user and the database, allowing data to be accessed using structured
commands (SQL) without needing to know how it’s stored internally.
Example: Student Result Management System
We use software like MySQL, Oracle, or MS Access to create the table, store marks, and perform
operations.
Example in MySQL:
CREATE TABLE Student (
RollNo INT PRIMARY KEY,
Name VARCHAR(50),
Marks INT
);
INSERT INTO Student VALUES (101, 'Amit', 89);
SELECT * FROM Student;
--------------------------------------------------------------------------------------------------------------------------------------
File system Vs. DBMS
File System
The file system is basically a way of arranging the files in a storage medium like a hard disk.
The file system organizes the files and helps in the retrieval of files when they are required.
File systems consist of different files which are grouped into directories.
The directories further contain other folders and files.
The file system performs basic operations like management, file naming, giving access rules,
etc.
DBMS ( Database Management System)
Database Management System is basically software that manages the collection of related
data.
It is used for storing data and retrieving the data effectively when it is needed.
It also provides proper security measures for protecting the data from unauthorized access.
In Database Management System the data can be fetched by SQL queries and relational
algebra.
It also provides mechanisms for data recovery and data backup.
Difference between File System and DBMS
Basics File System DBMS
Structure The file system is a way of DBMS is software for managing
arranging the files in a storage the database.
medium within a computer.
Data Redundant data can be present in a In DBMS there is no redundant
Redundancy file system. data.
Backup and It doesn't provide Inbuilt It provides in house tools for
Recovery mechanism for backup and backup and recovery of data even
recovery of data if it is lost. if it is lost.
Query There is no efficient query Efficient query processing is there
processing processing in the file system. in DBMS.
Consistency There is less data consistency in the There is more data consistency
file system. because of the process
of normalization .
Complexity It is less complex as compared to It has more complexity in handling
DBMS. as compared to the file system.
Security File systems provide less security DBMS has more security
Constraints in comparison to DBMS. mechanisms as compared to file
systems.
Cost It is less expensive than DBMS. It has a comparatively higher cost
than a file system.
User Access Only one user can access data at a Multiple users can access data at a
time. time.
Sharing Data is distributed in many files. Due to centralized nature data
So, it is not easy to share data. sharing is easy
Data It give details of storage and It hides the internal details
Abstraction representation of data of Database
Integrity Integrity Constraints are difficult to Integrity constraints are easy to
Constraints implement implement
--------------------------------------------------------------------------------------------------------------------------
Applications of DBMS
Railway Reservation System
The railway reservation system database plays a very important role by keeping record of ticket
booking, train's departure time and arrival status and also gives information regarding train late to
people through the database.
Library Management System
Now-a-days it's become easy in the Library to track each book and maintain it because of the
database. This happens because there are thousands of books in the library.
Now DBMS used to maintain all the information related to book issue dates, name of the book,
author and availability of the book.
Banking
Banking is one of the main applications of databases.
We all know there will be a thousand transactions through banks daily and we are doing this without
going to the bank.
This is all possible just because of DBMS that manages all the bank transactions.
Universities and colleges
Now-a-days examinations are done online. So, the universities and colleges are maintaining DBMS to
store Student's registrations details, results, courses and grade all the information in the database.
Credit card transactions
The purchase of items and transactions of credit cards are made possible only by DBMS.
A credit card holder has to know the importance of their information that all are secured through
DBMS.
Social Media Sites
By filling the required details we are able to access social media platforms.
Many users sign up daily on social websites such as Facebook, Pinterest and Instagram.
All the information related to the users are stored and maintained with the help of DBMS.
Finance
Now-a-days there are lots of things to do with finance like storing sales, holding information and
finance statement management etc. these all can be done with database systems.
Military
In military areas the DBMS is playing a vital role. Military keeps records of soldiers and it has so many
files that should be kept secure and safe. DBMS provides a high security to military information.
Online Shopping
Now-a-days we all do Online shopping without wasting the time by going shopping with the help of
DBMS. The products are added and sold only with the help of DBMS like Purchase information,
invoice bills and payment.
Airline Reservation system
Just like the railway reservation system, airlines also need DBMS to keep records of flights arrival,
departure and delay status.
--------------------------------------------------------------------------------------------------------------------------------------
Data abstraction
Data abstraction in a DBMS hides the complex details of data storage from users, presenting
them with a simplified view.
This allows users to interact with the database without needing to understand the underlying
physical storage or complex data structures.
It's like using a smartphone – you can make calls or send messages without knowing how the
phone's hardware and software work internally.
Levels of Data Abstraction with Practical Example
Let’s assume we're creating a Student Management System using MySQL
1. Physical Level (Lowest Level – How Data is Stored Physically)
User/Student doesn’t see this level.
It's about how data is actually stored in memory, like bytes, pages, indexing, etc.
We don't directly work with this in MySQL, but MySQL internally handles it.
2. Logical Level (Middle Level – What Data is Stored and Relationships)
This is where Database Administrators or Developers work.
They define tables, fields, data types, and relationships.
3. View Level (Highest Level – What the User Sees)
This is what end users or applications interact with.
We can create views to show only required data and hide the rest.
Examples:
ATM:
When you use an ATM, you don't see how the machine dispenses cash or how your account
information is accessed. The complex details of data storage and processing are hidden
from you.
Online Shopping:
When you browse products on an e-commerce site, you see a user-friendly interface with
product images, descriptions, and prices.
The DBMS handles all that complexity behind the scenes.
--------------------------------------------------------------------------------------------------------------
Data schema
A database schema is the blueprint or design of the database that defines how data is
organized and how relationships between data are handled.
It include
Tables:
Schemas define the tables that will hold your data. Each table represents a specific entity
e.g., customers, products, orders
Columns:
Within each table, columns represent the different attributes or characteristics of that entity
e.g., customer ID, name, address, phone number
Data Types:
Each column is assigned a specific data type e.g., integer, string, date to ensure data
consistency and integrity.
Relationships:
Schemas define how tables are related to each other
e.g., a customer can have multiple orders, an order belongs to one customer
Constraints:
Schemas also include constraints, which are rules that enforce data integrity.
Examples include primary keys (unique identifiers for each row), foreign keys (linking
tables together), and data validation rules.
Example :
Step 1: Create Schema (Database)
CREATE DATABASE CollegeDB;
USE CollegeDB;
Step 2: Define Tables (Schema Design)
CREATE TABLE Department (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(100) NOT NULL
);
----------------------------------------------------------------------------------------------------------------
Codd’s Rules
Dr. E. F. Codd, the father of relational databases, proposed 12 rules in 1985 to define what a
Relational Database Management System (RDBMS) must satisfy to be considered truly relational.
Rule 1: Information Rule
All data must be stored as values in tables (relations).
Data is represented in rows and columns only.
Rule 2: Guaranteed Access Rule
Every data item must be accessible using the table name, column name, and
primary key.
No need to know physical storage details to retrieve data.
Rule 3: Systematic Treatment of NULL Values
The DBMS must treat NULLs (missing or inapplicable information) consistently
across all operations.
NULLs must be distinct from zero or empty strings.
Rule 4: Active Online Catalog
The structure description of the entire database must be stored in an online catalog,
known as data dictionary, which can be accessed by authorized users.
Users can use the same query language to access the catalog which they use to access
the database itself.
Rule 6: View Updating Rule
All views (virtual tables) that are theoretically updatable should be actually
updatable by the system.
Rule 7: High-Level Insert, Update, and Delete
The system must support insert, update, and delete operations on sets of rows, not
just one row at a time.
Rule 8: Physical Data Independence
The data stored in a database must be independent of the applications that access the
database. Any change in the physical structure of a database must not have any impact
on how the data is being accessed by external applications.
Rule 9: Logical Data Independence
The logical data in a database must be independent of its users view (application).
Any change in logical data must not affect the applications using it.
Rule 10: Integrity Independence
A database must be independent of the application that uses it. All its integrity
constraints can be independently modified without the need of any change in the
application.
Rule 11: Distribution Independence
Users should be able to access data without knowing whether it is stored in one
place or multiple locations (distributed databases).
Rule 12: Non-subversion Rule
It must not be possible to bypass integrity rules by using low-level access methods.
All access to data should be through relational means only.
--------------------------------------------------------------------------------------------------------------------------------------
Two tier architecture of database
The 2-tier architecture is similar to a basic client-server model.
The application at the client end directly communicates with the database on the server side.
The server side is responsible for providing query processing and transaction management
functionalities.
On the client side, the user interfaces and application programs are run.
The application on the client side establishes a connection with the server side to
communicate with the DBMS.
For Example: A Library Management System used in schools or small organizations is a
classic example of two-tier architecture.
Client Layer (Tier 1): This is the user interface that library staff or users interact with. For
example they might use a desktop application to search for books, issue them, or check due
dates.
Database Layer (Tier 2): The database server stores all the library records such as book
details, user information, and transaction logs.
The client layer sends a request (like searching for a book) to the database layer which
processes it and sends back the result. This separation allows the client to focus on the user
interface, while the server handles data storage and retrieval.
----------------------------------------------------------------------------------------------------------------
Three tier architecture of database
In 3-Tier Architecture, there is another layer between the client and the server.
The client does not directly communicate with the server.
Instead, it interacts with an application server which further communicates with the database
system and then the query processing and transaction management takes place.
This intermediate layer acts as a medium for the exchange of partially processed data
between the server and the client.
This type of architecture is used in the case of large web applications.
Example: E-commerce Store
User: You visit an online store, search for a product and add it to your cart.
Processing: The system checks if the product is in stock, calculates the total price and
applies any discounts.
Database: The product details, your cart and order history are stored in the database for
future reference.
----------------------------------------------------------------------------------------------------------------
Hierarchical Data Model
A Hierarchical Data Model is a data model that organizes data in a tree-like structure,
where each record (called a node) has a single parent and potentially many children,
forming a one-to-many (1:N) relationship.
Structure of Hierarchical Model
The structure of the hierarchical model is similar to an organizational chart or file system:
Each record type represents a collection of related data.
Records are connected through parent-child relationships.
The topmost record is called the root node.
Child nodes can be further parents to other nodes, forming a hierarchy.
Example Structure
Organization (Root)
/ | \
HR Dept Finance Dept IT Dept
| | |
Employee A Employee B Employee C
In the above tree:
The root node is Organization.
The departments are children of the root.
Employees are children of departments.
Components of Hierarchical Model
1. Record (Node): A logical unit of data (e.g., employee, department).
2. Parent Record: A record that has one or more child records.
3. Child Record: A record that is subordinate to a parent.
4. Link or Pointer: A physical or logical connection between parent and child records.
5. Hierarchy Path: The access path from the root to any node in the structure.
----------------------------------------------------------------------------------------------------------------
Network Data Model
A Network Data Model is a data model that allows many-to-many (M:N) relationships using records
and sets. Unlike the hierarchical model, where each child has only one parent, in a network model a
record can have multiple parents and multiple children.
For example
In a College Database, a student can enroll in multiple courses, and a course can have multiple
students — this is a many-to-many relationship.
Students ⇄ Courses
This cannot be represented in hierarchical model, but is perfectly suited to the network
model.
Student Table
Student_I Student_Name
D
S01 Rahul
S02 Priya
S03 Aman
Course Table
Course_I Course_Name
D
C101 DBMS
C102 OS
C103 CN
Enrolment
Student_I Course_ID
D
S01 C101
S01 C102
S02 C101
S03 C102
S03 C103
Students Courses
-------- --------
Rahul (S01) --------→ DBMS (C101)
| ↘ OS (C102)
↓ ↘
Priya (S02) CN (C103)
↓
Aman (S03)
Rahul enrolled in DBMS & OS
Priya enrolled in DBMS
Aman enrolled in OS & CN
Each Course has multiple Students, and each Student takes multiple Courses.
This is the core power of network model: handling M:N relationships using sets with
owner-member pairs.
----------------------------------------------------------------------------------------------------------------
Relational Data Model
The Relational Data Model is a way to represent data in the form of relations (tables).
It was introduced by E.F. Codd in 1970.
Each relation consists of rows (tuples) and columns (attributes), and each relation represents an
entity in the real world.
Key Features:
Relation (Table):
A relation is a table with rows and columns. It stores data about an entity.
👉 Example: Student(StudentID, Name, DeptID)
Tuple (Row):
Each row in the table is a tuple and represents a single record.
👉 Example: (101, 'Anjali', 1)
Attribute (Column):
A column in the table that represents a property of the entity.
👉 Example: StudentID, Name, DeptID
Primary Key (PK):
A unique identifier for each tuple in a relation. It cannot be NULL.
👉 Example: StudentID is the primary key of Student table.
Foreign Key (FK):
An attribute in one table that refers to the primary key in another table, creating a link between tables.
👉 Example: DeptID in Student table refers to DeptID in Department table.
Domain:
The set of permissible values for an attribute.
👉 Example: Marks attribute may have a domain of 0–100.
Example:
Table 1: Student
StudentI Name DeptID
D
101 Anjali 1
102 Ravi 2
Table 2: Department
DeptI DeptName
D
1 CSE
2 ECE
DeptID is a foreign key in the Student table, referencing the Department table.
Advantages:
Easy to understand and use.
Supports powerful querying using SQL.
Maintains data integrity through keys and constraints.
Reduces redundancy with normalization.