Unit 1 - DBMS-II BSC
Unit 1 - DBMS-II BSC
(SBS1205)
2/22/2021 1
Course Objectives:
To understand the fundamental concepts of database management.
These concepts includeaspects of database design, database
languages, and database-system implementation
To use Structured Query Language (SQL) and design relational
database.
These concepts helps us to design good database and tell us how to
handle it.
To illustrate the concept of Transaction , Query processing and
various DatabaseArchitectures.
2/22/2021 2
These concepts explain various database architectures and query
processing.
To use scalable general purpose databases to handle big data.
These concepts explain how to handle big data.
Course Outcomes:
On completion of the course, student will be able to–
summarize fundamental concepts of database management.
Contents of DBMS
Books
Text Books:
Abraham Silberschatz, Henry Korth, S.Sudarshan,"Database System concepts",5 th
Edition ,McGraw Hill International Edition.
Connally T, Begg C., "Database Systems", Pearson Education, ISBN 81-7808-861-4
Pramod J. Sadalage and Martin Fowler, “NoSQL Distilled”,Addison Wesley,
ISBN10: 0321826620, ISBN-13: 978-0321826626
2/22/2021 5
Reference Books:
1.C J Date, “An Introduction to Database Systems”, Addison-Wesley, ISBN: 0201144719
2.S.K.Singh, “Database Systems : Concepts, Design and Application”, Pearson, Education,ISBN 978-
81-
317-6092-5
3.Kristina Chodorow, Michael Dirolf, “MangoDB: The Definitive Guide” ,O’Reilly Publications, ISBN:
978-1-449-34468-9.
4.Adam Fowler, “NoSQL For Dummies”, John Wiley & Sons,ISBN-1118905628
5.Kevin Roebuck, “Storing and Managing Big Data - NoSQL, HADOOP and More”, Emereopty
Limited, ISBN: 1743045743, 9781743045749
6. Joy A. Kreibich, “Using SQLite”, O'REILLY, ISBN: 13:978-93-5110-934-1
7. Garrett Grolemund, “Hands-on Programming with R”, O'REILLY, ISBN : 13:978-93-5110-728-6
2/22/2021 6
2/22/2021 6
Definition – Data
Data is raw, unorganized facts that need to beprocessed.
Data can be something simple and seemingly random and
useless until it is organized.
Example: Each student's test score is one piece of data.
"Data" comes from a singular Latin word, datum, which
originally meant "something given."
Over time "data" has become the plural ofdatum.
2/22/2021 8
2/22/2021
9
Definition–Information
When data is processed, organized, structured or presented
in a given context so as to make it useful, it is called
information.
Information is the processed data on which decisions and
actions are based.
2/22/2021 10
Example: The average score of a class or of the entire
school is information that can be derived from the given
data.
Definition – DBMS
A database is an organized collection of data. It is the
collection of tables, queries, reports, views and other
objects.
11
DBMS(Database Management System) is a collection of
interrelated data and a set of programs to access those data.
2/22/2021 12
Providing mechanisms for the manipulation of
information.
Ensure the safety of the information stored, despite system
crashes or attempts at unauthorized access.
If data are to be shared among several users, the system
must avoid possible anomalous results.
13
Application of DBMS
Banking
Airlines
Universities
Credit cardtransactions
Telecommunication
Finance
Sales
2/22/2021 14
Manufacturing
Human resources
Purpose of Database Systems
File-Processing System
A File processing system is a collection of files and programs
that access/modify these files.
Typically, new files and programs are added over time (by
different programmers) as new information needs to be stored
and new ways to access information are needed.
2/22/2021 15
Disadvantages of File Processing System
Data redundancy and inconsistency
Difficulty in accessing data
Data isolation
Concurrent-access anomalies
2/22/2021 16
Advantage of DBMS
Controlling Data Redundancy
Sharing of Data
Data Consistency
Data Integrity
Data Security
Data Independence
Backup and Recovery Procedures
2/22/2021 17
Disadvantage of DBMS
Increased costs
Management complexity
Frequent upgrade/replacement cycles
Database Damage
2/22/2021 18
View of Data
Major purpose of a database system is to provide users withan
abstract view of the data.
DataAbstraction
Data abstraction is the reduction of
a particular body of data to
a simplified representation of
the whole.
2/22/2021 19
Fig: Three Level of data abstractions
2/22/2021 22
The overall design of the database is called the database
schema.
2/22/2021 23
Instances and Schemas
Database systems have schemas at each level
of abstraction:
The physical schema describes the database design at the physical
level
i.e. as a file of records of a particular type
2/22/2021 24
A database may also have several schema's at the view level,
sometimes called subschemas, that describe different views of the
database.
For example, (Name, Account No) is a subschema of (Name, Account No,
Balance, Address)
2/22/2021 25
Database System Structure
Functions of DBA
Schema Definition.
2/22/2021 27
2/22/2021 21
Routine maintenance.
Data Models
Data Model is a collection of conceptual tools for describing
data, data relationships, data semantics, and consistency
constraints.
2/22/2021 28
Data models define how data is connected to each other and how
they are processed and stored inside the system.
2/22/2021 29
The Object-Oriented Model
1) Physical Data Models
Note: 1st & 2nd model describe data at the conceptual and view
levels and 3rd at physical level
Relational Model
The Relational model uses a collection of tables to
represent both data and the relationships among those data.
Tables are also known asrelations.
2/22/2021 30
Relation: made up of 2 parts:
Instance: a table, with rows and columns.
#rows =cardinality , #fields = degree / arity
Schema: specifies name of relation, plus name and type of
each column
E.g.: Students( sid: string, name: string, login: string,
age: integer, gpa: real)
2/22/2021 31
Relational Model Contd…
2/22/2021 26
Network Model
I n Network Model data are represented by collections
of records, and relationships among data are represented
by links.
Each record is a collection of fields (attributes), each of
which contains only one data value.
A link is an association between precisely two records
2/22/2021 33
Hierarchical Model
A Hierarchical Model consists of a collection of
records that are connected to each other through links.
A record is similar to a record in the network model.
2/22/2021 34
Each record is a collection of fields (attributes), eachof
which contains only one data value.
A link is an association between precisely two records
2/22/2021 35
Hierarchical Database Model
The Hierarchical Model mandates that each child
record has only one parent, whereas each parent record
can have one or more child records.
2/22/2021 36
I n order to retrieve data from a hierarchical database the
whole tree needs to be traversed starting from the root
node.
Entity-Relationship(E-R) Model
The entity-relationship (E-R) data model uses a collection of
basic objects, called entities, and relationships among these
objects.
2/22/2021 37
Entity − An entity in an ER Model is a “thing” or “object ” in the
real-world having properties called attributes.
2/22/2021 38
Every attribute is defined by its set of values calleddomain.
For example, a student's name cannot be a numeric value. It has to be
alphabetic. A student's age cannot be negative,etc.
2/22/2021 39
2/22/2021 40
E-R Model Contd…
Types ofAttributes
Simple attribute
Composite attribute
Derived attribute
Single-valued attribute
Multivalued attribute
Simple attribute − Simple attributes consist of atomic values,
which cannot be divided further.
2/22/2021 41
E-R Model Contd…
For example, a student's phone number is an atomic value of 10
digits
2/22/2021 43
E-R Model Contd…
2/22/2021 44
E-R Model Contd…
Mapping cardinalities −
Cardinality defines the number of entities in one entity set,
which can be associated with the number of entities of other
set via relationship set.
one to one
one to many many to one
many to many
2/22/2021 45
E-R Model Contd…
One-to-one - One entity from entity set Acan be associated with
at most one entity of entity set B and vice versa.
2/22/2021 38
2/22/2021 47
E-R Model Contd…
One-to-many − One entity from entity set A can be associated
with more than one entities of entity set B however an entity
from entity set B, can be associated with at most one entity.
2/22/2021 48
E-R Model Contd…
2/22/202139
E-R Model Contd…
Many-to-one − More than one entities from entity set A can be
associated with at most one entity of entity set B, however an
entity from entity set B can be associated with more than one
entity from entity setA.
2/22/2021 50
E-R Model Contd…
2/22/2021 41
2/22/2021 52
E-R Model Contd…
Cardinality Constraints
We express cardinality constraints by drawing either a directed
line (), signifying “one,” or an undirected line (—), signifying
“many,” between the relationship set and the entity set.
E.g.: One-to-one relationship:
2/22/2021 53
E-R Model Contd…
A customer is associated with at most one loan via the
relationship borrower
A loan is associated with at most one customer via borrower
Cardinality Constraints
In the one-to-many relationship a loan is associated with at
most one customer via borrower, a customer is associated with
several (including 0) loans via borrower
2/22/2021 54
E-R Model Contd…
2/22/2021 55
E-R Model Contd…
Cardinality Constraints
In a many-to-one relationship a loan is associated with several
(including 0) customers via borrower, a customer is associated
with at most one loan via borrower
2/22/2021 56
E-R Model Contd…
2/22/2021 57
E-R Model Contd…
Cardinality Constraints
A customer is associated with several (possibly 0) loans via
borrower
A loan is associated with several (possibly 0) customers via
2/22/2021 58
E-R Model Contd…
borrower
2/22/2021 59
E-R Model Contd…
2/22/2021 60
Contd…
E-R Model
2/22/2021 61
Contd…
E-R Model
2/22/2021 63
Contd…
2/22/2021 64
Keys
Key – A key for an entity is a set of attributes that suffice to
distinguish entities from each other or uniquely define that entity.
Types Superkey
Candidate Key
Primary Key
Foreign Key
2/22/2021 65
Superkey
Asuperkey is a set of one or more attributes that, taken collectively,
allow us to uniquely identify a tuple in the relation.
2/22/2021 66
Superkey Example
SuperKey- {Emp_ID}
{Emp_ID,Emp_Name},{Emp_ID,DOB},
{Emp_Name,DOB},
2/22/2021 67
{Emp_Name, DOB, Gender},...
2/22/2021 68
Candidate Key
Candidate key is nothing but minimal super keys for which no proper
subset is a super key.
SuperKey- {Emp_ID}
{Emp_ID,Emp_Name},{Emp_ID,DOB},
{Emp_Name,DOB},
{Emp_Name, DOB, Gender},...
Primary key entity in the set cannot have the same value for
two or more tuples i.e. unique and it cannot be null.
r1 - referencing relation
r2- referenced relation
2/22/2021 71
Foreign Key Example
2/22/2021 72
Referencing relation –Instructor
2/22/2021 73
The existence of a weak entity set depends on the existence of a
identifying entity set
The discriminator (or partial key) of a weak entity set is the set
of attributes that distinguishes among all the entities of a weak
entity set.
The primary key of a weak entity set is formed by the primary
key of the strong entity set on which the weak entity set is
existence dependent, plus the weak entity set’s discriminator.
2/22/2021 75
Extended E-R Diagram(EER)
2/22/2021 77
Extended E-R Diagram (EER)
2/22/2021 78
Extended E-R Diagram (EER)
EMPLOYEE is the superclass for each of these subclasses These
are called super-class/subclassrelationships.
Contd…
Example:
EMPLOYEE/SECRETARY,
EMPLOYEE/TECHNICIAN
2/22/2021 79
Extended E-R Diagram (EER)
Contd…
Specialization
Top-down design process; we designate subgrouping within an
entity set that are distinctive from other entities in the set.
2/22/2021 81
Extended E-R Diagram (EER)
Contd…
Specializatio n
Example
63
Contd…
Generalization
A bottom-up design process – combine a number of entity sets that
share the same features into a higher-level entity set.
Aggregation
One limitation of the E-R model is that it cannot express relationships among
relationships.
2/22/2021 84
Extended E-R Diagram (EER)
Contd…
2/22/2021 86
E-R Diagram for a
University Database
classroom(building, room number,
capacity) department(dept name, building,
budget) course(course id, title, dept name,
credits) instructor(ID, name, dept name,
salary)
section(course id, sec id, semester, year, building,
room number, time slot id)
teaches(ID, course id, sec id, semester, year)
student(ID, name, dept name, tot cred)
2/22/2021 87
E-R Diagram for a
takes(ID, course id, sec id, semester, year, grade)
advisor(s ID, i ID)
time slot(time slot id, day, start time, end time)
prereq(course id, prereq id)
E-R Diagram for a
University Database
E-R Diagram for a
2/22/2021 68
E-R Diagram for a
Banking Enterprise
E-R Diagram for a
2/22/2021 69
Attributes -
Simple/Single valued – column in table
Weak Entity Set – Separate table for weak entity withall attributes
along with primary key of identifying entity.
2/22/2021 93
Converting EER diagram
intotables
Relationship set – Separate table consist of primary key of all
entities participating in relation.
Specialization/Generalization – Separate table for higher level
and lower level entity set.
eg. person(ID,name,street,city)
employee(ID,salary) student(ID,
marks)
2/22/2021 94
Aggregation – Consist of all primary keys for aggregate
relationship and entity.
2/22/2021 95
Two Types of Ordered index :
1. Dense Index
2. Sparse Index
2/22/2021 96
END
OF UNIT
I
2/22/2021 74