0% found this document useful (0 votes)
3 views47 pages

DBMS Unit1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views47 pages

DBMS Unit1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

DATABASE MANGEMENT SYSTEMS

Unit-1 Database System Concepts


&
Relation Models and Database Design using ER
Model

Dr Abdul Ahad

1
1. Introduction to DBMS
What Is a DBMS?
• A very large, integrated collection of data.
• DBMS de ne as “A software that provide an
environment that is both convenient and e cient to
use in storing and retrieving the data of an
enterprise”.
• A Database Management System (DBMS) is a set of
programs or a software package designed to store and
manage databases.
• DBMS contains information about a particular
enterprise. For example, Entities (e.g., customer, product,
transaction)
Relationships (e.g., Abdul purchased a laptop )
Dr Abdul Ahad 2
Introduction to DBMS (Cont.
)
A Sample Database: University
STUDENT table DEPARTMENT table
Std_ID Std_Name Dept_Name Std_Phone Dept_name Building Dept_Phone
S001 Mahesh AI 9812345670 AI E 9800000111
S002 Ram CSE 9812345671 CSE A 9800000122
S003 Pawan AI 9812345672 IT H 9800000133
S004 Charan IT 9812345673 DS H 9800000144
S005 Arjun CSE 9812345674 ECE E 9800000155
FACULTY table
Fac_ID Fac_Name Dept_Name Salary Fac_Phone
T001 Abdul AI 50000 9812345690
T002 Pardeep CSE 45000 9812345691
T003 Manoj AI 35000 9812345692
T004 Raju CSE 45000 9812345693
T005 Sridhar AI 40000 9812345694
Dr Abdul Ahad 3
Introduction to DBMS
(Cont.)
DBMS allows users the following tasks
• Data
modi De
cation, nition:
and It
removal helps
of de in the
nitions thatcreation,
de ne
the organization of data in the database.
• Data
modi Updation:
cation, and It
deletion helps
of the in the
actual insertion,
data in the
database.
• Data
from Retrieval:
the It
database helps in
which the
can retrieval
be of
used data
by
applications for various purposes.
• User Administration:
monitoring users, It helps
enforcing in registering
data and
security,
monitoring
dealing performance,
with concurrency maintaining
control, anddata integrity,
recovering
information corrupted by unexpected failure.
Dr Abdul Ahad
Introduction to DBMS
(Cont.)
Key Features of DBMS
1. Data modeling: A DBMS provides tools for creating and
modifying data models, which de ne the structure and
relationships of the data in a database.
2. Data storage and retrieval: A DBMS is responsible for storing
and retrieving data from the database, and can provide
various methods for searching and querying the data.
3. Concurrency control: A DBMS provides mechanisms for
controlling concurrent access to the database, to ensure that
multiple users can access the data without con icting with
each other.
4. Data integrity and security: A DBMS provides tools for
enforcing data integrity and security constraints, such as
constraints on the values of data and access controls that
restrict who can access the data.
5. Backup and recovery: ADr Abdul DBMSAhadprovides mechanisms for5
backing up and recovering the data in the event of a system
Introduction to DBMS (Cont.
)
Characteristics of
DBMSThe DBMS is developed in such a way that it can
1. Real World Entity:
manage huge business organizations and store their business data with
security.
2. Self-explaining nature: So the self-explaining nature means the Database
explains all the information automatically itself. This is because, in the
Database, all the data are stored in a structured format.
3. Atomicity of Operations (Transactions)
4. Concurrent Access without Anomalies: Here the term anomalies mean
multiuser can access the Database and fetch the information without any
problem.
5. Stores Any Kind of Structured Data
6. Integrity
7. Ease of Access (The DBMS Queries): In DBMS, we can search any kind of
stored data by applying a simple search operation query. It is so much faster
than manual searching.
8. SQL and No-SQL Databases: The SQL databases store the data in the
form of Tables, i.e., rows and columns. The No-SQL databases can store data
in any form other than a table. For instance: the very popular MongoDB
stores the data in the form of JSON (JavaScript Object Notation).
9. ACID Properties: ACID standsDrfor Atomicity,
Abdul Ahad Consistency, Isolation, and 6
Durability.
Introduction to DBMS
(Cont.)
Advantages & Disadvanges of DBMS
Advantages
Controls database redundancy: It can control data
redundancy because it stores all the data in one single
database le and that recorded data is placed in the database.
Data sharing: In DBMS, the authorized users of an
organization can share the data among multiple users.
Easily Maintenance: It can be easily maintainable due to the
centralized nature of the database system.
Reduce time: It reduces development time and maintenance
need.
Backup: It provides backup and recovery subsystems which
create automatic backup of data
from hardware and software failures and restores the data if
required.
Multiple user interface: It provides di erent types of user
Dr Abdul Ahad 7
Introduction to DBMS (Cont.)
Disadvantages of DBMS
Cost of Hardware and Software: It requires a high
speed of data processor and large memory size to
run DBMS software.
Size: It occupies a large space of disks and large
memory to run them e ciently.
Complexity: Database system creates additional
complexity and requirements.
Higher impact of failure: Failure is highly impacted
the database because in most of the organization, all
the data stored in a single database and if the
database is damaged due to electric failure or
database corruption then the data may be lost forever.
Dr Abdul Ahad 8
2. Database-System
Applications
Enterprise Information: Sales, Accounting, Human
Resources, Manufacturing, Online Retailers
Banking and Finance: Banking, Credit card transactions,
Finance
Universities: Students Information, Course Registration ,
Grades
Airlines: Reservation, Flight Schedule
Telecommunication: Monthly Bills, Pre-Paid and Post-
Paid Call Records, Recorded calls
Sales: customers, products, purchases
Online retailers: order tracking, customized
recommendations
Manufacturing: production, inventory, orders, supply
chain Dr Abdul Ahad 9
3. Purpose of Database System
(Why DBMS?)
In the early days, database applications were built on top of le
systems.
The drawbacks of le systems are:
● Data redundancy and inconsistency: multiple les or
duplication of information in di erent les.
● Di culty in accessing data: need to write a new program
to carry out each new task.
● Data isolation: multiple le formats.
● Integrity problems: integrity constraints (e.g. account balance
> 0) become part of program code and hard to add new
constraints or change existing ones.
● Atomicity of updates : failures may leave database in an
inconsistent state with partial updates carried out. For
example, transfer of funds from one account to another
Dr Abdul Ahad 10
Purpose of Database Systems
(Cont.)
● Concurrent access by multiple users: concurrent
accessed needed for performance and uncontrolled
concurrent accesses can lead to inconsistencies. For
example, two people reading a balance and updating
it at the same time
● Security problems
Database systems o er solutions to all the above
problems:
Data independence and e cient access.
Reduced application development time.
Data integrity and security.
Uniform data administration.
Dr Abdul Ahad 11
Purpose of Database Systems
(Cont.)
Files System vs.
DBMS

Dr Abdul Ahad 12
4. Levels of Abstraction
( View of Data )

Dr Abdul Ahad 13
Levels of Abstraction (Cont.)
Physical level (or Internal View): The lowest level of abstraction, which
explain how the data is actually stored the internal schema is written using
data definition language. It describes how a record (e.g., customer) is stored.
Logical level (Conceptual View): The next highest level of abstraction,
where the entire information of the database is displayed. It is used by DBA,
who must decide what information is to be kept in the database. It describes
data stored in database, and the relationships among the data.
type customer = record
customer_id : string;
customer_name : string;
customer_city : string;
customer_phone : integer;
end;
View level (or External View): The highest level of abstraction is
external view, where only those portion of the database are displayed,
which are requested by the user, but not entire database. External view
has a permission to de ne the records and relationship, That can14be
stored in the database. Views can also hide information (e.g., salary) for
Dr Abdul Ahad
5. Database Architecture
(Structure of Database Management System)
∙ An architecture( or structure) of Database Management
System

Dr Abdul Ahad 15
Database Architecture (cont.)
The database system architecture is divided into three
components: Query Processor, Storage Manager, and
Disk Storage.
Query Processor: It interprets the requests (queries)
received from end-user via an application program into
instructions. It also executes the user request which is
received from the DML compiler.
Query Processor contains the following components –
• DML Compiler: It processes the DML statements into low
level instruction (machine language), so that they can be
executed.
• DDL Interpreter: It processes the DDL statements into a set
of table containing meta data (data about data).
• Embedded DML Pre-compiler: It processes DML statements
embedded in an application program
Ahad into procedural calls.
• Query Optimizer: It executes the instruction generated by
Dr Abdul 16
Database Architecture (cont.)
Storage Manager: It is a program that provides an interface between the
data stored in the database and the queries received. It maintains the
consistency and integrity of the database by applying the constraints and
executing the DCL statements. It is responsible for updating, storing, deleting,
and retrieving data in the database. It contains the following components:
• Authorization Manager: It checks whether the particular person is
privileged to perform the requested operation or not.
• Integrity Manager: It checks the integrity constraints when the database is
modi ed.
• Transaction Manager: It controls concurrent access by performing the
operations in a scheduled way that it receives the transaction.
• File Manager: It manages the le space and the data structure used to
represent information in the database.
• Bu er Manager: It is responsible for cache memory and the transfer of data
between the secondary storage and main memory.
Disk Storage: It contains the following components:
• Data Files: It stores the data.
• Data Dictionary: It contains the information about the structure of any
database object. It is the repositoryDrofAbdul
information
Ahad that governs the metadata. 17
Database Architecture (cont.)
2-Tier Vs 3-Tair Database Architecture

▪ Two-tier architecture: E.g. client programs using ODBC/JDBC to


communicate with a database
▪ Three-tier architecture: E.g. web-based applications, and applications built
using “middleware” Dr Abdul Ahad 18
6. Database
Users: Users are diUsers
erentiated by the way they expect to interact with the
system
● Application programmers – interact with system through DML calls
● Sophisticated users – form requests in a database query language
● Specialized users – write specialized database applications that
do not t into the traditional data processing framework
● Naïve users – invoke one of the permanent application programs
that have been wri en previously
E.g. people
Database accessing database
Administrator (DBA): overCoordinates
DBA the web, bank
all tellers,
the clerical
activities of
sta
the database system; the database Administrator has a good
understanding of the enterprise’s information resources and needs.
Database Administrator's duties include:
✔ Schema de nition
✔ Storage structure and access method de nition
✔ Schema and physical organization modi cation
✔ Granting user authority to access the database
✔ Specifying integrity constraints
✔ Acting as liaison with users
✔ Monitoring performance and responding
Dr Abdul Ahad to changes in 19
7. Relational
Relational modelModel
can represent as a table with columns
(a ributes) and rows (tuples). COURSE table
A Sample Relational Database:
Crs_ID Crs_Name Dept_Name Credits

University STUDENT table C001 DBMS AI 5


Std_ID Std_Name Dept_Name Std_Phone C002 DS CSE 5
S001 Mahesh AI 981234567 C003 JAVA IT 3
0 C004 PYTHON AI 3
S002 Ram CSE 981234567 C005 DAA DS 3

REGISTRATION table
1
S003 Pawan AI 981234567
Std_ID Crs_ID Sec_ID Sem Year
2
S004 Charan IT 981234567 S001 C001 A 2 2
3 S002 C002 B 1 2
S005 Arjun CSE 981234567 S003 C003 A 2 2
4 S004 C004 B 1 2
Dr Abdul AhadS005 C005 A 2 2 20
Relational Model (
Terminology cont. )
ASTD_ID,
ribute: It contains the name of
STD_NAME, CRS_ID, CRS_NAME.
a column in a particular table. e.g.;
Domain: It contains a set of atomic values that an a ribute can take.
Tuple: Each row in the relation is known as a tuple.
Relational key: In the relational key, each row has one or more
a ributes. It can identify the row in the relation uniquely.
Relation Schema: A relation schema de nes the structure of the
relation and represents the name of the relation with its a ributes.
COURSE (CRS_ID, CRS_NAME, DEPT_NAME, CREDITS) is the relation schema for
e.g.;
COURSE.
Relation Instance: The set of tuples of a relation at a particular
instance of time is called a relation instance. Relation instances do not
have duplicate tuples
NULL Values: The value which is not known or unavailable is called a
NULL value.
Degree: The number of a ributes in the relation is known as the
degree of the relation. The STUDENT relation de ned above has 21
degree 4. Dr Abdul Ahad
Relational Model (
cont. )
Types of Constraints (Keys)
Primary Key: A primary key is a key by which we can uniquely identi es each
row of the table and prevents NULL values. A table can have only one primary
key constraint.
Foreign Key: A foreign key is a key by which we can refers the columns of the
another table. A table can have any number of foreign key constraint. When a
foreign key refers the columns of the same table then it is called self
referencing foreign key.
Default Value: The default value speci ed will be used when you do not
specify any value for the column while inserting data. If a default value is not
explicitly set, the default for the column is implicitly set to NULL.
NOT NULL: Prevents NULL values from being entered into the column. These
types of constraints are de ned on a single column. By default, Oracle allows
NULL values in any column. A NOT NULL constraint is de ned at the column
level; it cannot be de ned at the table level.
CHECK: Ensures that the value in a column meets a speci c condition
UNIQUE: Any unique column will not allow duplicate values to be present in it.
However there can be two orDrmore
Abdul than
Ahad two NULL in the unique column
22
8. Database Design
▪ Database design can be generally de ned as a
collection of tasks or processes that enhance the
designing, development, implementation, and
maintenance of enterprise data management system.
▪ Designing a proper database reduces the
maintenance cost thereby improving data consistency
and the cost-e ective measures are greatly
in uenced in terms of disk storage space.
▪ The designer should follow the constraints and decide
how the elements correlate and what kind of data
must be stored.
▪ The main objectives behind database designing are to
produce physical and logical design models of the
proposed database system.
Dr Abdul Ahad 23
Database Design
Instances and(cont.)
Schemas
Database change from time to time as information is inserted
and deleted. The view of collection of information stored in the
database at that particular moment is called an “instance” of
the database, whereas the overall design (plan) of the
database to store the information is called as the database
“schema”. It is the logical structure of the database (e.g., the
database consists of information about a set of customers and
accounts and the relationship between them)
● Physical schema: database design at the physical level
● Logical schema: database design at the logical level

Physical Data Independence – the ability to modify the


physical schema without changing the logical schema
● Applications depend on the logical schema
● In general, the interfaces between the various levels and
components should beDr Abdul
wellAhadde ned so that changes 24in
Database Design
(cont.)
Logical Data Independence - It presents data in the form
that can be accessed by the end users. Logical data
independence says that users should be able to manipulate
the logical view of data without any information of its physical
storage. Software or the computer program is used to
manipulate the logical view of the data.
● Database administrator is the one who decides what
information is to be kept in the database and how to use
the logical level of abstraction.
● It provides the global view of Data.
● It also describes what data is to be stored in the database
along with the relationship.
● The changes in the logical level may include −
▪ Change the data de nition.
▪ Adding, deleting, or updating any new a ribute, entity or
relationship in the database.
Dr Abdul Ahad 25
Database Design

(cont.)
The logical database design model is primarily concentrated on the
requirements of data and the considerations must be made in terms
of monolithic considerations and hence the stored physical data must
be stored independent of the physical conditions.
▪ The physical database design model includes a translation of the
logical design model of the database by keep control of physical
media using hardware resources and software systems such as
Database Management System (DBMS).
Why is Database Design important?
i. Database designs provide the blueprints of how the data is going to be
stored in a system. A proper design of a database highly a ects the overall
performance of any application.
ii. The designing principles de ned for a database give a clear idea of the
behavior of any application and how the requests are processed.
iii. Another instance to emphasize the database design is that a proper
database design meets all the requirements of users.
iv. Lastly, the processing time of an application is greatly reduced if the
constraints of designing a highlyDreAbdul
cientAhad
database are properly implemented.26
Database Design (
Database cont. )
Schemaschema is the logical design of the database, and a
Database
database schema de nes how data is organized within a
relational database; this is inclusive of logical constraints such
as, table names, elds, data types and the relationships
between these entities. The database instance, which is a
snapshot of the data in the database at a given instant in time.
For example,
• department (dept_name, building, dept_phone)

Dept_name Building Dept_Phone


AI E 9800000111
CSE A 9800000122
IT H 9800000133
DS H 9800000144
ECE E 9800000155
The department
Dr Abdulrelation.
Ahad 27
Database Design (
cont. )
Schema for University
• Database (dept_name, building, dept_phone)
department
• classroom (room_no, building, capacity)
• course (crs_id, crs_name, dept_name, credits)
• section (sec_id, crs_id, sem, year, building, room_no, _id)
• faculty (fac_id, fac_name, dept_name, salary, fac_phone)
• teaches (fac_id, crs_id, sec_id, sem, year)
• student (std_id, std_name, dept_name, std_phone)
• takes (std_id, crs_id, sec_id, sem, year)
• timetable ( _id, day, start_time, end_time)
• mentor (std_id, fac_id)
Dr Abdul Ahad 28
Database Design ( cont. )
Schema Diagrams: A database schema, along with primary
key and foreign key dependencies, can be depicted by schema
diagrams.
For example, Schema diagram for the University Database.

Dr Abdul Ahad 29
9. Entity Relationship
Model (ER
• ER model standsDiagram)
for an Entity-Relationship model. It is a
high-level data model. This model is used to de ne the
data elements and relationship for a speci ed system.
• In ER modeling, the database structure is portrayed as a
diagram called an entity-relationship diagram.
• An Entity Relationship Diagram (ER Diagram) pictorially
explains the relationship between entities to be stored in
a database.
• ER Modelling is a systematic process to design a
database as it would require you to analyze all data
requirements before implementing your database.
Dr Abdul Ahad 30
ER Model ( cont.
Symbols Used in ER) Diagrams

Components of ER model

Dr Abdul Ahad 31
ER Model ( cont.
)
As shown in the above diagram, an ER diagram has three main
components: 1. Entity 2. A ribute 3. Relationship
Entity: An entity is an object or component of data. An entity is
represented as rectangle in an ER diagram. An entity is anything in
the real world, such as an object, class, person, or place.
Entity set: An entity set is a group of entities of similar kinds. It
can contain entities with a ributes that share similar values. An Entity
is an object of Entity Type and a set of all entities is called an entity
set.
▪ Strong Entity: A Strong Entity is a type of entity that has a key
A ribute. 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: Some entity type exists for which key a ributes can’t
be de ned. Weak Entity depend on other Entity in the Schema.
These are called Weak Entity types.
Dr Abdul AhadIt is represented by a double
32
ER Model ( cont.
)
A ributes: A ributes are the properties that de ne the
entity type. For example, Roll_No, Name, DOB, Age, Address,
and Mobile_No are the a ributes that de ne entity type
Student. In ER diagram, the a ribute is represented by an oval.
Key A ribute: The a ribute which uniquely identi es each
entity in the entity set is called the key a ribute. For example,
Roll_No will be unique for each student. In ER diagram, the key
a ribute is represented by an oval with underlying lines.
Composite A ribute: An a ribute composed of many other
a ributes is called a composite a ribute. For example, the Address
a ribute of the student Entity type consists of Street, City, State, and
Country.

Dr Abdul Ahad 33
ER Model ( cont.
)
Multivalued A ribute: An a ribute consisting of more than one value for
a given entity. In ER diagram, a multivalued a ribute is represented by a
double oval.

Derived A ribute: An a ribute that can be derived from other a ributes


of the entity type is known as a derived a ribute. e.g.; Age (can be derived
fromExample
An DOB). InofERDi diagram,
erent the derived
Types of a ribute is represented by a dashed
Aoval.ributes

Dr Abdul Ahad 34
ER Model (
cont. )
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.

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.

Dr Abdul Ahad 35
ER Model ( cont.
)
Degree of a Relationship Set: The number of di erent entity sets
participating in a relationship set is called the degree of a
relationship set.
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.
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.

n-ary Relationship: When there are n entities set participating in a relation,


the relationship is called an n-ary relationship.
Dr Abdul Ahad 36
ER Model ( cont.
)
Cardinality: The number of times an entity of an entity
set participates in a relationship set is known
as cardinality. Cardinality can be of di erent types:
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. The total number of tables that can be used in this is 2.
Using Sets, it can be represented as:

Dr Abdul Ahad 37
ER Model ( cont.
)
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. Using sets, one-to-many
cardinality can be represented as:

Many-to-One: When entities in one entity set can take part only
once in the relationship set and entities in other entity sets can take
part more than once in the relationship set, cardinality is many to one.
Let us assume that a student can take only one course but one course
can be taken by many students. So the cardinality will be n to 1. The
total number of tables that can be used in this is 3.

Dr Abdul Ahad 38
ER Model ( cont.
)
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. The total
number of tables that can be used in this is 3. Using Sets, it
can be represented as:

Dr Abdul Ahad 39
ER Model ( cont.
)
Aggregation: Aggregation is used when we have to
model a relationship involving (entity sets and) a
relationship set. It allows us to treat a relationship set
as an entity set for purposes of participation in
(other) relationships.
Aggregation vs. ternary
relationship:
❖ Monitors is a distinct relationship, with
a
descriptive a ribute.
❖ Also, can say that each sponsorship is
monitored by at most one employee.

Dr Abdul Ahad 40
ER Model ( cont.
)
Steps for designing ER-model

Step 1 − Identify the entities from the given database.


Step 2 − Find relationships among entities.
Step 3 − Identify the key a ribute for every entity.
Step 4 − Identify the other relevant a ribute.
Step 5 − Draw the complete E-R diagram with all the
a ributes including primary key.
Step 6 - Review your results according to the
requirements of
the database.
Dr Abdul Ahad 41
ER Model ( cont.
)
For Example: ER Model for a College/University Database

Dr Abdul Ahad 42
ER Model ( cont.
)

Dr Abdul Ahad 43
ER Model ( cont.
)

Dr Abdul Ahad 44
ER Model ( cont.
)

Dr Abdul Ahad 45
ER Model ( cont.
)
Department_Name Location

DEPARTMENT

Offers Handed Has


by

Course_ID

COURSE Is taught by FACULTY


Credits

Faculty_ID Room_No
Course_Name Duration

Faculty_Name
Enrolled Phone_No
by

Gender

STUDENT DoB

Student_ID
Student_Name
Dr Abdul Ahad 46
THANK YOU

Dr Abdul Ahad 47

You might also like