Unit 1
Unit 1
The core of any database management system is the data itself. Another important aspect
regarding DBMS is the difference between data and information.
Data: It is the unorganised facts which need to be compiled to form meaningful information
Information: Once the data is processed and made into a structured context, it is called
information.
The database is a collection of inter-related data which is used to retrieve, insert and delete the
data efficiently. It is also used to organize the data in the form of a table, schema, views, and
reports, etc.
For example: The college Database organizes the data about the admin, staff, students and
faculty etc.
Using the database, you can easily retrieve, insert, and delete the information.
A Database Management System (DBMS) is a software system that facilitates the creation,
organization, management, and retrieval of data from a database. It serves as an interface
between the database and the users or application programs, providing a systematic way to
store, retrieve, and manage information. The primary functions of a DBMS include data
storage, data retrieval, and data manipulation. A database management system (DBMS) refers
to the technology for creating and managing databases. DBMS is a software tool to organize
(create, retrieve, update, and manage) data in a database.
• Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used in
different applications.
• DBMS provides an interface to perform various operations like database creation,
storing data in it, updating data, creating a table in the database and a lot more.
• It provides protection and security to the database. In the case of multiple users, it also
maintains data consistency.
The main aim of a DBMS is to supply a way to store up and retrieve database information that
is both convenient and efficient. By data, we mean known facts that can be recorded and that
have embedded meaning.
File System
File Systems” were nothing but a manual way of storing data as “Files”. Considering a
scenario of a bank before the introduction of DBMS, for example, say someone went to the
bank to deposit a certain amount in their account. So as the DBMS is not available so the
bank employee has to manually register their account number, name, and amount in either a
written manner or type and store them locally in the computer as a file. The problem which
might arise that while writing if the employee mistakenly writes any digit of their account
number or amount wrong then there would be a major issue and as there is no Database so it
would be hard to know what was the last state of that person’s account before this misshaped
deposit.
In the diagram above we can see how the details used to be stored by bank employees before
the introduction of DBMS. Each department would handle some specific tasks and store the
data locally in their computers or registers without knowing what is happening in the other
department.
File Processing System :
In Computer Science, File Processing System (FPS) is a way of storing, retrieving and
manipulating data which is present in various files.
Files are used to store various documents. All files are grouped based on their categories.
The file names are very related to each other and arranged properly to easily access the files.
In file processing system, if one needs to insert, delete, modify, store or update data, one must
know the entire hierarchy of the files.
In earlier days, data was stored manually, using pen and paper but after computer was
discovered, the same task could be done by using files. A computer File is a resource which
uniquely records data, in a storage device. in a computer. There are various formats in which
data can be stored. e.g. Text files can be stored in .txt format while pictures can be stored in
.png format etc.
Characteristics of Traditional File Systems
Following are some of the notable characteristics of Traditional File Systems:
• The data of certain companies or organizations were kept as “Files”.
• The files stored in different departments were independent of each other, which
caused severe data redundancy.
• Those files were developed using programming languages like COBOL, C, and
C++.
• Each file includes information for a particular department or region, such as the
library, tuition, and students’ exams.
• The traditional file system is way less flexible than DBMS and has many
disadvantages.
• The maintenance of those files was also of high cost.
File processing systems in database management have several issues and limitations
compared to modern database management systems (DBMS). Here are some common issues
associated with file processing systems:
1. Data Redundancy:
o In a file processing system, data redundancy is high. The same data may be
stored in multiple files, leading to increased storage requirements and potential
inconsistencies.
o Changes to data in one file may not be reflected in other related files, leading
to data discrepancies.
2. Data Inconsistency:
o Since data is duplicated across multiple files, there is a risk of inconsistencies.
If an update is made to one copy of the data and not to others, it can lead to
data integrity problems.
3. Data Isolation:
o Data isolation is a challenge in file systems because data is typically stored in
separate files with little or no relationship between them. This makes it
difficult to retrieve and update related data efficiently.
4. Data Dependence:
o Changes in the structure of the data (e.g., adding a new field or modifying the
data format) require modification of all programs that access that data. This
tight coupling can lead to maintenance challenges.
5. Limited Security:
o File processing systems often lack sophisticated security mechanisms. Access
control is limited, and it may be challenging to enforce data privacy and
protection.
6. Concurrency Control:
o Ensuring data consistency in a multi-user environment is challenging in file
systems. File locking mechanisms may be primitive, leading to issues such as
data corruption or lost updates.
7. Difficulty in Querying and Reporting:
o Retrieving and querying data in a file processing system can be complex.
There is typically no query language, and extracting information requires
custom programming.
8. Scalability Issues:
o File systems may struggle to handle a growing volume of data efficiently. As
the data grows, the performance of the system may degrade, impacting
response times and overall efficiency.
9. Limited Data Integrity Constraints:
o Enforcing data integrity constraints (e.g., primary keys, foreign keys) is often
left to application programs, making it more prone to errors.
10. Lack of Data Independence:
o Changes in the data structure require modifications in the application
programs, resulting in a lack of data independence.
11. No Transaction Management:
o File systems generally lack transaction management features, making it
difficult to maintain the consistency of the database in the event of failures or
errors.
Modern DBMS, such as relational database management systems (RDBMS), address many
of these issues through features like data normalization, transaction management, data
independence, and enhanced security mechanisms. They provide a more structured and
efficient approach to data management compared to traditional file processing systems.
• Lack of atomicity-
Operations performed in the database must be atomic i.e. either the operation
takes place as a whole or does not take place at all.
• Data Organization and Structure- A DBMS helps organize and structure data in a
systematic way. It provides a centralized repository where data is stored, making it
easier to manage and retrieve information.
• Data Integrity- DBMS enforces data integrity constraints, such as unique constraints,
primary keys, and foreign keys, to ensure the accuracy and reliability of data.
• Data Independence- DBMS provides a level of abstraction between the physical
storage of data and the way it is presented to applications. This allows changes in the
data structure without affecting the applications that use the data.
• Data Security- DBMS includes robust security mechanisms to control access to data.
User authentication, authorization, and encryption help protect sensitive information
from unauthorized access.
• Concurrency Control- In multi-user environments, a DBMS ensures that multiple
users can access and modify data concurrently without compromising data
[Link] manages concurrent access to prevent conflicts and data corruption.
• Redundancy and inconsistency in the data – The data redundancy problem of the
Traditional File System has been minimized by the DBMS, here one piece of data can
be present in a single place only without scattering throughout multiple places
• Data Exchange – Exchange of Data between two or more devices have become so
hassle-free with the introduction of the Database system. As a single database is
accessible by every employee anyone can make any changes to the database or
exchange data with each other.
• Concurrent Data – DBMS provides a locking system using which one or more
users can only read the same data but can’t make any changes simultaneously.
• Searching Data – In the case of the Traditional file systems, the programmer needs
to write lengthy programs everytime to fetch certain information, with DBMS some
2-3 line query is enough to fetch as many data as we want. Also, one language is
supported by many databases (with a slight variety of syntax).
• Data Reliability – Data reliability is also high in DBMS as it supports user-defined
data types also apart from the traditional in-built data types.
• System Failure – As DBMS follows ACID properties, even if a system failure
happens in between a transaction, nothing will be lost, and we can restart that
transaction from its previous stable state.
• Data Protection – DBMS comes up with lots of methods to protect the data stored
inside it rather than just Passwords
• Backup of Data – Data Backup is possible in DBMS, which was not present in the
Traditional File systems.
• Variation of Interfaces – DBMS comes with different kinds of interfaces like
Graphicals or Tabular.
• Maintenance of the Database – As DBMS is a centralized structure it is easier to
maintain it rather than the Traditional File systems
The foundation of database systems is a broad vocabulary that facilitates communication about
the numerous facets of data storage, administration, and retrieval. In order to further your
comprehension, we will go through the important terms used in database systems in this article,
along with comprehensive explanations and applicable examples.
• Entity − An entity is a specific real-world thing or idea that we wish to represent and
keep data about. For instance, students, professors, courses, and departments might all
be considered entities in a university database
• Attribute − An attribute is a representation of a particular quality or trait of an entity.
It outlines the information about the entity that we wish to store. A student entity, for
instance, may include characteristics like a student ID, name, date of birth, and major.
• Key − A key is an entity's or an entity instance's particular set of properties that
uniquely identify it. For data integrity and effective data retrieval, keys are necessary.
To ensure that each student has a distinct identification, the student ID, for instance,
may act as the primary key in the student object
• Table − A relational database system's core structure for organizing data into rows and
columns is a table. Each table is made up of columns (attributes) and rows (records),
and it represents a single entity. For instance, a table called "Students" may have
columns for student data such as student ID, name, and major.
• Primary Key − A primary key is a way for a table to be uniquely identified. It
guarantees that each row in the table can be identified individually. A single column or
a group of columns might serve as the primary key. The student ID column, for
instance, may serve as a primary key in the "Students" database.
• Foreign Key − A column or group of columns in one database that relate to the primary
key in another table is known as a foreign key. This creates a connection between the
two tables. For instance, to link students with the courses they are registered for, a
foreign key in the "Courses" database can make reference to the primary key in the
"Students" field.
• Relational Database − A relational database is a kind of database system that arranges
information into tables and uses keys to create relationships between those tables. It
provides a systematic and effective method of managing data by adhering to the
fundamentals of the relational model. Popular relational database systems include
PostgreSQL, Oracle, and MySQL.
• Query − Requesting data or information from a database is known as a query. It enables
users to obtain, manipulate, and manage data and is described using a query language
like SQL. For instance, a query may return a list of every student registered for a certain
course.
• Index − A database table's index is a type of data structure that accelerates data retrieval
processes. Based on the indexed column(s), it enables easy access to specified data. In
the "Students" database, for instance, an index on the student ID column would speed
up searches looking for students by their ID.
• Normalization − Normalization is the process of arranging data in a database to reduce
duplication and strengthen data integrity. It entails breaking down tables and creating
connections between them. Normal forms are a set of guidelines that the normalization
process abides by. A normalization process can involve dividing a single database
containing student and course data into distinct "Students" and "Courses" tables.
• ACID − Atomicity, Consistency, Isolation, and Durability, or simply ACID, are
characteristics that guarantee the dependability and integrity of database transactions.
A transaction will always be seen as a single piece of work thanks to atomicity. A
transaction moves the database from one legitimate state to another by guaranteeing
consistency. Concurrent transactions are prevented from interfering with one another
through isolation. Durability ensures that changes made during a transaction are
permanent and will endure any future system failures.
• Data Warehouse − An organization's data warehouse is a sizable, integrated, and
unified collection of information from numerous sources. It is intended to be used for
decision-making, reporting, and analysis. For the purposes of business intelligence and
data analytics, data warehouses often store historical and aggregated data
• Data Mining − Finding patterns, trends, and insights from huge databases is referred
to as data mining. In order to extract useful knowledge and information, statistical and
machine-learning approaches are applied. To find hidden patterns and provide
predictions or suggestions based on the data, data mining techniques are utilized.
• Backup and Recovery − Backup and recovery procedures are crucial for guaranteeing
data availability and guarding against data loss. In order to offer a restoration point in
the event of a system failure or data corruption, backup entails making copies of the
database at regular intervals. Recovery entails utilizing the backup copies to restore the
database to a consistent condition.
To guarantee that client data can be recovered in the event of hardware failures or
unintentional deletions, a database administrator, for instance, may plan daily backups
of a customer database.
• Replication − Replication is the process of making and keeping copies of a database
or specific sections of a database on several servers. It increases fault tolerance,
scalability, and data availability. Asynchronous or synchronous replication guarantees
that changes made to one duplicate are replicated to the others.
For instance, in a distributed e-commerce system, product information may be
duplicated over several servers to make sure that users can easily access product details
no matter where they are.
• Data Dictionary − A data dictionary, sometimes referred to as a metadata repository,
is a central repository for details on the objects and the schema of a database. It includes
metadata including table and column names, data types, restrictions, and table
connections. The DBMS uses the data dictionary to verify queries, uphold data
integrity, and offer details on the database architecture.
The "Employees" table, for instance, may be described in the data dictionary together
with the names and data types of its columns, such as "Employee ID," "First Name,"
"Last Name," and "Salary."
• Database Schema − A database schema outlines the logical organization and structure
of a database. The tables, columns, data types, restrictions, and connections between
the tables are all described. A blueprint for building and running the database is
provided by the schema. A database design for an online shop, for instance, would have
tables like "Books," "Authors," and "Orders," each with specific fields, data types, and
connections.
There are several types of DBMS Architecture that we use according to the usage requirements.
Types of DBMS Architecture are discussed here.
• 1-Tier Architecture
• 2-Tier Architecture
• 3-Tier Architecture
1-Tier Architecture
In 1-Tier Architecture the database is directly available to the user, the user can directly sit on
the DBMS and use it that is, the client, server, and Database are all present on the same
machine. For Example: to learn SQL we set up an SQL server and the database on the local
system. This enables us to directly interact with the relational database and execute operations.
• Simple Architecture: 1-Tier Architecture is the most simple architecture to set up, as
only a single machine is required to maintain it.
• Cost-Effective: No additional hardware is required for implementing 1-Tier
Architecture, which makes it cost-effective.
• Easy to Implement: 1-Tier Architecture can be easily deployed, and hence it is mostly
used in small projects
2-Tier Architecture
The 2-tier architecture is like a basic client-server model. The application at the client end
directly communicates with the database on the server side. APIs like ODBC and JDBC are
used for this interaction. 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.
An advantage of this type is that maintenance and understanding are easier, and compatible
with existing systems. However, this model gives poor performance when there are a large
number of users.
• Easy to Access: 2-Tier Architecture makes easy access to the database, which makes
fast retrieval.
• Scalable: We can scale the database easily, by adding clients or upgrading hardware.
• Low Cost: 2-Tier Architecture is cheaper than 3-Tier Architecture and Multi-Tier
Architecture.
3-Tier Architecture
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.
Advantages of 3-Tier Architecture
Data Models
• A Hierarchical model
• Network model
• ER Model
• Relational Model
• Object-Oriented Data Model
A Hierarchical Model
The hierarchical data model was the first DBMS-based model. This model organizes data in
a hierarchical tree structure. The hierarchy begins at the root, which contains root data.
It then expands into a tree adding child nodes to the parent node. This model can easily
represent some real-world relationships, such as sitemaps and recipes for food, or even website
navigation.
1. One to many relationships: Here, the data is organized in a tree-like manner where
there is a one-to-many relationship between data types. There can only be one path from
any parent to any node. Example: If we want to get to the root node, there is only one
way to do so.
2. Parent-Child Relationship Every child node has its parent node, but a parent can have
more than one child. Multiple parents are prohibited.
3. Deletion Issue: When a parent node has been deleted, the child node will also be
deleted.
4. Pointers: Pointers link the parent and child nodes. They are used for navigation
between stored data.
A network model is nothing but a generalization of the hierarchical data model as this data
model allows many to many relationships therefore in this model a record can also have more
than one parent. The network data model extends the hierarchical model by allowing each
child to have multiple parents. It uses a graph-like structure, where records can be connected
to multiple records. While more flexible than the hierarchical model, it is also less commonly
used in modern database systems.
The network model in DBMS can be represented as a graph and hence it replaces the
hierarchical tree with a graph in which object types are the nodes and relationships are the
edges.
This model can consist of multiple parent segments and these segments are grouped as levels
but there exists a logical association between the segments belonging to any level. Mostly,
there exists a many-to-many logical association between any of the two segments. We called
graphs the logical associations between the segments. Therefore, this model replaces the
hierarchical tree with a graph-like structure, and with that, there can more general connections
among different nodes. It can have M: N relations i.e, many-to-many
Here, a relationship is called a set, and each set is made up of at least 2 types of record which
are given below:
In the above figure, member TWO has only one owner ‘ONE’ whereas member FIVE has two
owners i.e, TWO and THREE. Here, each link between the two record types represents 1 : M
relationship between them. This model consists of both lateral and top-down connections
between the nodes. Therefore, it allows 1: 1, 1 : M, M : N relationships among the given entities
which helps in avoiding data redundancy problems as it supports multiple paths to the same
record.
Example: In this example, we can see that a node student has two parents. CSE Department
and Library. In the hierarchical structure, this was not possible.
Characteristics Of Network Model
1. Ability To Merge More Relationships: In this model, data is more closely related to
more relationships. This model can manage both one-to-one and many-to-many
relationships.
2. Many routes: Because there are many relationships, there may be multiple paths to the
same record. This allows data access to be quick and easy.
3. Circular Link List: The operations on the network model can be done using the circular
linked list. A program maintains the current position and navigates through the records
based on the relationship. The physical structure of the network model is
• Data can be accessed more quickly than the hierarchical model. Because the data in the
network model is more closely related, and it is possible to take more than one route to
reach a particular point, this is why the data can be accessed faster. The data can
therefore be accessed in many different ways.
• Data integrity is guaranteed because there is a parent/child relationship. Any changes
in the parent record are reflected in a child record.
• The system can become more complicated as more relationships are needed to be
managed. To be able to use the model, the user must have a good understanding of it.
• Any type of change, such as updating, deletion, or insertion, is extremely complex.
An Entity-Relationship model is a high-level data model that describes the structure of the
database in a pictorial form which is known as ER-diagram. In simple words, an ER diagram
is used to represent logical structure of the database easily.
ER model develops a conceptual view of the data hence it can be used as a blueprint to
implement the database in the future.
Developers can easily understand the system just by looking at ER diagram. Let's first have a
look at the components of an ER diagram.
• Entity - Anything that has an independent existence about which we collect the data.
They are represented as rectangles in the ER diagram. For example - Car, house, employee.
• Entity Set - A set of the same type of entities is known as an entity set. For example -
Set of students studying in a college.
They are represented as rectangles in the ER diagram. For example - Car, house, employee.
• Entity Set - A set of the same type of entities is known as an entity set. For example -
Set of students studying in a college.
• Attributes - Properties that define entities are called attributes. They are represented
by an ellipse shape.
• Relationships - A relationship in DBMS is used to describe the association between
entities. They are represented as diamond or rhombus shapes in the ER diagram.
In the above-represented ER diagram, we have two entities that are Employee and Company,
and the relationship among them. Also, in the above-represented ER diagram, we can see that
both the employee and company have some attributes and the relationship is of "works in"
type, which means the employee works in a company.
Relational Model
This is the most widely accepted data model. In this model, the database is represented as a
collection of relations in the form of rows and columns of a two-dimensional table. Each row
is known as a tuple (a tuple contains all the data for an individual record) while each column
represents an attribute. For example -
The above table shows a relation "STUDENT" with attributes such as Stu. Id, Name, and
Branch which consists of 4 records or tuples.
Since data is stored as objects we can easily store audio, video, images etc in the database
which was very difficult and inconvenient to do in the relational model. As shown in the
image below two objects are connected with each other through links.
• Objects –
An object is an abstraction of a real world entity or we can say it is an instance of
class. Objects encapsulates data and code into a single unit which provide data
abstraction by hiding the implementation details from the user.
• Attribute –
An attribute describes the properties of object. For example: Object is STUDENT and
its attribute are Roll no, Branch, Setmarks() in the Student class.
• Methods –
Method represents the behavior of an object. Basically, it represents the real-world
action. For example: Finding a STUDENT marks in above figure as Setmarks().
• Class –
A class is a collection of similar objects with shared structure i.e. attributes and
behavior i.e. methods. An object is an instance of class.
class student
{
char Name[20];
int roll_no;
--
--
public:
void search();
void update();
}
The Entity Relational Model is a model for identifying entities to be represented in the database
and representation of how those entities are related. The ER data model specifies enterprise
schema that represents the overall logical structure of a database graphically.
The Entity Relationship Diagram explains the relationship among the entities present in the
database. ER models are used to model real-world objects like a person, a car, or a company
and the relation between these real-world objects. In short, the ER Diagram is the structural
format of the database.
• ER diagrams are used to represent the E-R model in a database, which makes them
easy to be converted into relations (tables).
• These diagrams are very easy to understand and easy to create even for a naive user.
• Lines: Lines represent attributes to entities and entity sets with other relationship
types.
Components of ER Diagram
Entity- An Entity may be an object with a physical existence – a particular person, car, house,
or employee – or it may be an object with a conceptual existence – a company, a job, or a
university course.
Entity Set: An Entity is an object of Entity Type and a set of all entities is called an entity set.
For Example, E1 is an entity having Entity Type Student and the set of all students is called
Entity Set. In ER diagram, Entity Type is represented as:
Strong Entity- A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not
depend on other Entity in the Schema. It has a primary key, that helps in identifying it uniquely,
and it is represented by a rectangle. These are called Strong Entity Types.
Weak Entity- An Entity type has a key attribute that uniquely identifies each entity in the entity
set. But some entity type exists for which key attributes can’t be defined. These are called Weak
Entity types.
For Example, A company may store the information of dependents (Parents, Children,
Spouse) of an Employee. But the dependents don’t have existed without the employee. So
Dependent will be a Weak Entity Type and Employee will be Identifying Entity type for
Dependent, which means it is Strong Entity Type.
Attributes- Attributes are the properties that define the entity type. For example, Roll_No,
Name, DOB, Age, Address, and Mobile_No are the attributes that define entity type Student.
In ER diagram, the attribute is represented by an oval.
Key Attribute- The attribute which uniquely identifies each entity in the entity set is called
the key attribute. For example, Roll_No will be unique for each student. In ER diagram, the
key attribute is represented by an oval with underlying lines.
Composite Attribute- An attribute composed of many other attributes is called a composite
attribute. For example, the Address attribute of the student Entity type consists of Street, City,
State, and Country. In ER diagram, the composite attribute is represented by an oval comprising
of ovals.
Multivalued Attribute- An attribute consisting of more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In ER diagram, a multivalued
attribute is represented by a double oval.
Derived Attribute- An attribute that can be derived from other attributes of the entity type is
known as a derived attribute. e.g.; Age (can be derived from DOB). In ER diagram, the derived
attribute is represented by a dashed oval.
The Complete Entity Type Student with its Attributes can be represented as:
Relationship Type and Relationship Set- A Relationship Type represents the association
between entity types. For example, ‘Enrolled in’ is a relationship type that exists between entity
type Student and Course. In ER diagram, the relationship type is represented by a diamond and
connecting the entities with lines.
Entity-Relationship Set- A set of relationships of the same type is known as a relationship set.
The following relationship set depicts S1 as enrolled in C2, S2 as enrolled in C1, and S3 as
registered in C3.
The number of different entity sets participating in a relationship set is called the degree of a
relationship set.
1. Unary Relationship: When there is only ONE entity set participating in a relation, the
relationship is called a unary relationship. For example, one person is married to only one
person.
2. Binary Relationship: When there are TWO entities set participating in a relationship, the
relationship is called a binary relationship. For example, a Student is enrolled in a Course.
3. n-ary Relationship: When there are n entities set participating in a relation, the relationship
is called an n-ary relationship.
Cardinality
The number of times an entity of an entity set participates in a relationship set is known as
cardinality. Cardinality can be of different types:
1. One-to-One: When each entity in each entity set can take part only once in the relationship,
the cardinality is one-to-one. Let us assume that a male can marry one female and a female can
marry one male. So the relationship will be one-to-one.
2. One-to-Many: In one-to-many mapping as well where each entity can be related to more
than one relationship and the total number of tables that can be used in this is 2. Let us assume
that one surgeon deparment can accomodate many doctors. So the Cardinality will be 1 to M.
It means one deparment has many Doctors.
In this case, each student is taking only 1 course but 1 course has been taken by many students.
4. Many-to-Many: When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a student can take more than one
course and one course can be taken by many students. So the relationship will be many to
many.
In this example, student S1 is enrolled in C1 and C3 and Course C3 is enrolled by S1, S3, and
S4. So it is many-to-many relationships.
When we compare the manual process with the university management system, the university
management system makes easier the overall process of the university management system.
The university management system creates a platform that collaborates with all students,
administrators, faculty, and stakeholders.
University Management System ER Diagram Tables
The below table shows all about the field name of the table, description, datatype, and character
length. Each table of the ER diagram defines and explains the data storage.