Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Basics of DBMS and E R Diagram

What is a Database?
A database is a collection of related data which represents
some aspect of the real world.

What is DBMS?
Database Management System (DBMS) is a software for
storing and retrieving users' data while considering
appropriate security measures. It consists of a group of
programs which manipulate the database

Characteristics of Database Management System


 Provides security and removes redundancy
 Self-describing nature of a database system
 Support of multiple views of the data
 Sharing of data and multiuser transaction processing
 DBMS allows entities and relations among them to
form tables.
 It follows the ACID concept ( Atomicity,
Consistency, Isolation, and Durability).
 DBMS supports multi-user environment that allows
users to access and manipulate data in parallel.

Popular DBMS Software


Here, is the list of some popular DBMS system:
 MySQL
 Microsoft Access
 Oracle
 PostgreSQL
 dBASE
 FoxPro
 SQLite
 IBM DB2
 LibreOffice Base
 MariaDB
 Microsoft SQL Server etc.
Application of DBMS
Sector Use of DBMS
Banking For customer information, account
activities, payments, deposits, loans, etc.
Airlines For reservations and schedule
information.
Universities For student information, course
registrations, colleges and grades.
Telecommunication It helps to keep call records, monthly
bills, maintaining balances, etc.
Finance For storing information about stock,
sales, and purchases of financial
instruments like stocks and bonds.
Sales Use for storing customer, product &
sales information.
Manufacturing It is used for the management of supply
chain and for tracking production of
items. Inventories status in warehouses.
HR Management For information about employees,
salaries, payroll, deduction, generation
of paychecks, etc.

File System to DBMS


File System manages data using files in hard disk. Users are
allowed to create, delete, and update the files according to
their requirement.
The example of file based University Management System.
Data of students is available to their respective Departments,
Academics Section, Result Section, Accounts Section, Hostel
Office etc. Some of the data is common for all sections like
Roll No, Name, Father Name, Address and Phone number of
students but some data is available to a particular section only
like Hostel allotment number which is a part of hostel office.
Let us discuss the issues with this system:
 Redundancy of data: Data is said to be redundant
if same data is copied at many places. If a student
wants to change Phone number, he has to get it
updated at various sections. Similarly, old records
must be deleted from all sections representing that
student.
 Inconsistency of Data: Data is said to be
inconsistent if multiple copies of same data does not
match with each other. If Phone number is different
in Accounts Section and Academics Section, it will
be inconsistent. Inconsistency may be because of
typing errors or not updating all copies of same data.
 Difficult Data Access: A user should know the
exact location of file to access data, so the process is
very cumbersome and tedious. If user wants to
search student hostel allotment number of a student
from 10000 unsorted students’ records, how
difficult it can be.
 Unauthorized Access: File System may lead to
unauthorized access to data. If a student gets access
to file having his marks, he can change it in
unauthorized way.
 No Concurrent Access: The access of same data by
multiple users at same time is known as
concurrency. File system does not allow
concurrency as data can be accessed by only one
user at a time.
 No Backup and Recovery: File system does not
incorporate any backup and recovery of data if a file
is lost or corrupted.

Types of DBMS Architecture


There are three types of DBMS architecture:

1. Single tier architecture


2. Two tier architecture

3. Three tier architecture

1. Single tier 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.

Referred as local database system


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 are used for the interaction between
server and client.

. Three tier architecture

Physical Level
This is the lowest level in the three level architecture. It is also
known as the internal level. The physical level describes how
data is actually stored in the database.
At the physical level, the information about the location of
database objects in the data store is kept. Various users of
DBMS are unaware of the locations of these objects.In simple
terms,physical level of a database describes how the data is
being stored in secondary storage devices like disks and tapes
and also gives insights on additional storage details.

Conceptual Level
The conceptual level is at a higher level than the physical
level. It is also known as the logical level.
At conceptual level, data is represented in the form of various
database tables. For Example, STUDENT database may
contain STUDENT and COURSE tables which will be visible
to users but users are unaware of their storage.Also referred as
logical schema,it describes what kind of data is to be stored in
the database.

The conceptual level does not care for how the data in the
database is actually stored.

External Level
This is the highest level in the three level architecture and
closest to the user. It is also known as the view level. The
external level only shows the relevant database content to the
users in the form of views and hides the rest of the data. So
different users can see the database as a different view as per
their individual requirements.
An external level specifies a view of the data in terms of
conceptual level tables. Each external level view is used to
cater to the needs of a particular category of users. For
Example, FACULTY of a university is interested in looking
course details of students, STUDENTS are interested in
looking at all details related to academics, accounts, courses
and hostel details as well. So, different views can be generated
for different users. The main focus of external level is data
abstraction.
View of data In dbms

View of data in DBMS narrate how the data is visualized at


each level .
Hiding irrelevant details from user and providing abstract
view of data to users, helps in easy and efficient user-
database interaction.
The view level provides the “view of data” to the users and
hides the irrelevant details such as data relationship, database
schema, constraints, security etc from the user.

There is one more feature that should be kept in mind i.e.


the data independence. While changing the data schema at
one level of the database must not modify the data schema at
the next level.
Data Abstraction
Data abstraction is hiding the complex data structure in
order to simplify the user’s interface of the system. It is done
because many of the users interacting with the database
system are not that much computer trained to understand the
complex data structures of the database system.

Instances and Schemas

We can define an instance as the information stored in the


database at a particular point of time. .

As we discussed above the database comprises of several


entity sets and the relationship between them. Now, the data
in the database keeps on changing with time. As we keep
inserting or deleting the data to and from the database.

Now, at a particular time if we retrieve any information from


the database then that corresponds to an instance.

schema
Whenever we talk about the database the developers have to
deal with the definition of database and the data in the
database.

The definition of a database comprises of the description of


what data it would contain what would be the relationship
between the data. This definition is the database schema.

Data models in DBMS


Data Model is a logical structure of Database. It describes the
design of database to reflect entities, attributes, relationship
among data, constrains etc.
Types of Data Models
There are several types of data models in DBMS.

Object based logical Models – Describe data at the


conceptual and view levels.

 E-R Model

 Object oriented Model

Record based logical Models – Like Object based model,


they also describe data at the conceptual and view levels.
These models specify logical structure of database with
records, fields and attributes.

 Relational Model
 Hierarchical Model

 Network Model – Network Model is same as


hierarchical model except that it has graph-like
structure rather than a tree-based structure. Unlike
hierarchical model, this model allows each record to
have more than one parent record.
Physical Data Models – These models describe data at the
lowest level of abstraction.

Entity Relationship Diagram – ER Diagram in DBMS

An Entity–relationship model (ER model) describes the


structure of a database with the help of a diagram, which is
known as Entity Relationship Diagram (ER Diagram). An
ER model is a design or blueprint of a database that can later
be implemented as a database. The main components of E-R
model are: entity set and relationship set.
What is an Entity Relationship Diagram (ER Diagram)?
An ER diagram shows the relationship among entity sets. An
entity set is a group of similar entities and these entities can
have attributes. In terms of DBMS, an entity is a table or
attribute of a table in database, so by showing relationship
among tables and their attributes, ER diagram shows the
complete logical structure of a database.

 Entity − An entity in an ER Model is a real-world entity


having properties called attributes. Every attribute is
defined by its set of values called domain. For example,
in a school database, a student is considered as an entity.
Student has various attributes like name, age, class, etc.

An entity is an object or component of data. An entity is


represented as rectangle in an ER diagram.

For example: In the following ER diagram we have two


entities Student and College and these two entities have many
to one relationship as many students study in a single college.
We will read more about relationships later, for now focus on
entities.

 Relationship − The logical association among entities is


called relationship. Relationships are mapped with
entities in various ways. Mapping cardinalities define
the number of association between two entities.
Mapping cardinalities −
o one to one

o one to many
o many to one
o many to many

Student college

A simple ER Diagram:

In the following diagram we have two entities Student and


College and their relationship. The relationship between
Student and College is many to one as a college can have
many students however a student cannot study in multiple
colleges at the same time. Student entity has attributes such as
Stu_Id, Stu_Name & Stu_Addr and College entity has
attributes such as Col_ID & Col_Name.
Here are the geometric shapes and their meaning in an E-R
Diagram.

Weak Entity:
An entity that cannot be uniquely identified by its own
attributes and relies on the relationship with other entity is
called weak entity. The weak entity is represented by a double
rectangle. For example – a bank account cannot be uniquely
identified without knowing the bank to which the account
belongs, so bank account is a weak entity.

2. Attribute
An attribute describes the property of an entity. An attribute is
represented as Oval in an ER diagram. There are four types of
attributes:
1. Key attribute

2. Composite attribute

3. Multivalued attribute

4. Derived attribute

1. Key attribute:
A key attribute can uniquely identify an entity from an entity
set.

For example, student roll number can uniquely identify a


student from a set of students. Key attribute is represented by
oval same as other attributes however the text of key
attribute is underlined.

2. Composite attribute:
An attribute that is a combination of other attributes is known
as composite attribute. For example, In student entity, the
student address is a composite attribute as an address is
composed of other attributes such as pin code, state, country.

3. Multivalued attribute:
An attribute that can hold multiple values is known as
multivalued attribute. It is represented with double ovals in an
ER Diagram. For example – A person can have more than one
phone numbers so the phone number attribute is multivalued.

4. Derived attribute:
A derived attribute is one whose value is dynamic and derived
from another attribute. It is represented by dashed oval in an
ER Diagram. For example – Person age is a derived attribute
as it changes over time and can be derived from another
attribute (Date of birth).
E-R diagram with multivalued and derived attributes:

Types of relationships
1. One to One Relationship
When a single instance of an entity is associated with a single
instance of another entity then it is called one to one
relationship. For example, a person has only one passport and
a passport is given to one person.

2. One to Many Relationship


When a single instance of an entity is associated with more
than one instances of another entity then it is called one to
many relationship. For example – a customer can place many
orders but a order cannot be placed by many customers.
3. Many to One Relationship
When more than one instances of an entity is associated with
a single instance of another entity then it is called many to one
relationship. For example – many students can study in a
single college but a student cannot study in many colleges at
the same time.

4. Many to Many Relationship


When more than one instances of an entity is associated with
more than one instances of another entity then it is called
many to many relationship. For example, a can be assigned to
many projects and a project can be assigned to many students.

Generalization

Generalization is a process in which the common attributes


of more than one entities form a new entity. This newly
formed entity is called generalized entity.
Generalization Example
Lets say we have two entities Student and Teacher.

Attributes of Entity Student are: Name, Address & Grade

Attributes of Entity Teacher are: Name, Address & Salary

The ER diagram before generalization looks like this:

These two entities have two common attributes: Name and


Address, we can make a generalized entity with these
common attributes. Lets have a look at the ER model after
generalization.

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).
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.

Specialization Example
g

>

You might also like