Introduction To DBMS
Introduction To DBMS
Introduction to DBMS
Database
According to the principles of database systems, the data is stored in such a way that it
acquires lot less space as the redundant data (duplicate data) has been removed before
storage.
Example
In a banking system, suppose a customer is having two accounts, one is saving account and
another is salary account. Let’s say bank stores saving account data at one place (these
places are called tables we will learn them later) and salary account data at another place,
in that case if the customer information such as customer name, address etc. are stored at
both places then this is just a wastage of storage (redundancy/ duplication of data), to
organize the data in a better way the information should be stored at one place and both the
accounts should be linked to that information somehow. The same thing we achieve in
DBMS.
Fast Retrieval of data
Along with storing the data in an optimized and systematic manner, it is also important that
we retrieve the data quickly when needed.
Database systems ensure that the data is retrieved as quickly as possible.
Purpose of Database Systems
Easy recovery: Since database systems keeps the backup of data, it is easier to do a full
recovery of data in case of a failure.
Flexible: Database systems are more flexible than file processing systems.
Disadvantages of DBMS
Performance: Database systems are generic, making them suitable for various applications.
However this feature affect their performance for some applications
Question?
What is a database?
a) Organized collection of information that cannot be
accessed, updated, and managed
b) Collection of data or information without organizing
c) Organized collection of data or information that can be
accessed, updated, and managed
d) Organized collection of data that cannot be updated
Question
What is DBMS?
a) DBMS is a collection of queries
b) DBMS is a high-level language
c) DBMS is a programming language
d) DBMS stores, modifies and retrieves data
Components of DBMS
Hardware, Software, Data, Database Access Language, Procedures and Users all together
form the components of a DBMS.
Hardware
Data is that resource, for which DBMS was designed. The motive
behind the creation of DBMS was to store and utilize data.
Database users are categorized based up on their interaction with the database.
These are different types of database users in DBMS:
Database Administrator (DBA)
Naive / Parametric End Users
System Analyst
Sophisticated Users
Database Designers
Application Programmers
Casual Users / Temporary Users
1. Database Administrator (DBA)
Parametric End Users are the unsophisticated who don’t have any
DBMS knowledge but they frequently use the database applications
in their daily life to get the desired results.
For examples, Railway’s ticket booking users are naive users.
Clerks in any bank is a naive user because they don’t have any
DBMS knowledge but they still use the database and perform their
given task.
3. System Analyst
Data Base Designers are the users who design the structure of
database which includes tables, indexes, views, triggers, stored
procedures and constraints which are usually enforced before the
database is created or populated with data.
He/she controls what data must be stored and how the data items to
be related.
It is responsibility of Database Designers to understand the
requirements of different user groups and then create a design which
satisfies the need of all the user groups.
6. Application Programmers
Casual Users are the users who occasionally use/access the database
but each time when they access the database they require the new
information.
For example, Middle or higher level manager.
DBMS Architecture
In this type of architecture, the database is readily available on the client machine, any
request made by client doesn’t require a network connection to perform the action on the
database.
For example, lets say you want to fetch the records of employee from the database and the
database is available on your computer system, so the request to fetch employee details
will be done by your computer and the records will be fetched from the database by your
computer as well. This type of system is generally referred as local database system.
Single tier architecture
• Any changes or updates that are done will reflect directly to the database.
• The 1-tier architecture is used for the development of applications where a programmer
directly communicates with the database for very fast response.
It is used for enhancement of the local application.
Example
In two-tier architecture, the Database system is present at the server machine and the
DBMS application is present at the client machine, these two machines are connected with
each other through a reliable network as shown in the above diagram.
Whenever client machine makes a request to access the database present at server using a
query language like sql, the server perform the request on the database and returns the
result back to the client.
The application connection interface such as JDBC, ODBC(Open Database Connectivity)
are used for the interaction between server and client.
When there are a large number of users at client side to access the database, this
architecture gives a poor performance.
The server side is responsible for delivering the functionalities like query processing and
management of transactions.
In three-tier architecture, another layer is present between the client machine and server
machine.
In this architecture, the client application doesn’t communicate directly with the database
systems present at the server machine, rather the client application communicates with
server application and the server application internally communicates with the database
system present at the server.
• Mainly, the 3-tier is used for large applications on the web.
• The features of 3-tier architecture are data backup, recovery, security, and concurrency
control.
Layers
This layer is also called the client layer. The front-end layer
Presentation layer −
consists of a user interface. The main purpose is to communicate with the
application layer.
This layer is also called the business logic layer. It acts as a
Application layer −
middle layer between the client and the database server which are used to
exchange partially processed data.
Database layer − In
this layer the data or information is stored. This layer performs
operations like insert, update and delete to connect with the database.
Example
Question
Entity types are the basic building blocks for describing the
structure of data. It's a category of a particular entity in
an entity set.
In summary, an Entity is an object of a Type Entity and the set of
all entities is called an entity set.
For Example: E1 is an entity having Entity Type Student and set of
all students is called Entity Set.
Example
Symbols Used in ER Diagrams
Types of Entities
Multivalued attributes are attributes that can have more than one
value. The double oval is used to represent a multivalued
attribute.
For example, the mobile_number of a student is a multivalued
attribute as one student can have more than one mobile number.
Derived attribute
Derived attributes are the ones that can be derived from other
attributes of an entity type. The derived attributes are represented
by a dashed oval symbol in the ER diagram.
For example, the age attribute can be derived from the date of
birth (DOB) attribute. So, it's a derived attribute.
Example
One-to-One Relationship
One-to-Many Relationship
Many-to-One Relationship
Many-to-Many Relationship
One-to-One Relationship
When a single element of an entity is associated with more than one element of
another entity, it is called a one-to-many relationship
For example, a customer can place many orders, but an order cannot be placed by
many customers.
Many-to-One Relationship
When more than one element of an entity is related to a single element of another
entity, then it is called a many-to-one relationship.
For example, students have to opt for a single course, but a course can have many
students.
Many-to-Many Relationship
When more than one element of an entity is associated with more than one
element of another entity, this is called a many-to-many relationship.
For example, you can assign an employee to many projects and a project can have
many employees.
How to Draw an ER Diagram?
The Participation of an entity set E in a relationship set R is said to be total if every entity
in E participates in at least one relationship in R.
Partial Participation
The participation of an entity set E in relationship set R is said to be partial if only some
entities in E participate in relationships in R.
Example
DBMS Generalization
These two entities have two common attributes: Name and Address, we can make a
generalized entity with these common attributes.
The ER diagram after generalization
We have created a new generalized entity Person and this entity has the common attributes
of both the entities.
As you can see in the following ER diagram that after the generalization process the
entities Student and Teacher only has the specialized attributes Grade and Salary
respectively and their common attributes (Name & Address) are now associated with a new
entity Person which is in the relationship with both the entities (Student & Teacher).
NOTE
Generalization uses bottom-up approach where two or more lower level entities combine
together to form a higher level new entity.
The new generalized entity can further combine together with lower level entity to create a
further higher level generalized entity.
DBMS Specialization
Specialization is a process in which an entity is divided into sub-entities. You can think of
it as a reverse process of generalization, in generalization two entities combine together to
form a new higher level entity. Specialization is a top-down process.
The idea behind Specialization is to find the subsets of entities that have few distinguish
attributes.
For example – Consider an entity employee which can be further classified as sub-entities
Technician, Engineer & Accountant because these sub entities have some distinguish attributes.
In the above diagram, we can see that we have a higher level entity “Employee” which we
have divided in sub entities “Technician”, “Engineer” & “Accountant”. All of these are just
an employee of a company, however their role is completely different and they have few
different attributes.
Just for the example, Here it is shown that Technician handles service requests, Engineer
works on a project and Accountant handles the credit & debit details. All of these three
employee types have few attributes common such as name & salary which we had left
associated with the parent entity “Employee” as shown in the above diagram.
DBMS Aggregation
Aggregation is a process in which a single entity alone is not able to make sense in a
relationship so the relationship of two entities acts as one entity.
Example:
In real world, we know that a manager not only manages the employee working under
them but he has to manage the project as well. In such scenario if entity “Manager” makes
a “manages” relationship with either “Employee” or “Project” entity alone then it will not
make any sense because he has to manage both.
In these cases the relationship of two entities acts as one entity.
In our example, the relationship “Works-On” between “Employee” & “Project” acts as one
entity that has a relationship “Manages” with the entity “Manager”.
Relational Model
Relational Model
Example to store the name, the CGPA attained, and the roll number of all the students of
a particular class.
Note
A table is a collection of data represented in rows and columns. Each table has a name in
database.
For example, the following table “STUDENT” stores the information of students in
database.
Record or Tuple:
Each row of a table is known as record. It is also known as tuple.
It is the logical blueprint of the relation i.e., it describes the design and
the structure of the relation.
For our Student relation example, the relational schema will be:
STUDENT(ROLL_NUMBER INTEGER, NAME VARCHAR(20), CGPA FLOAT)
Relation Key