01 Database Management
01 Database Management
Subject Code:22319
PCP,NIGDI, Mrs.S.S.Jogdand 1
Teaching Scheme
PCP,NIGDI, Mrs.S.S.Jogdand 2
UNIT NAME &
WEIGHTAGE
PCP,NIGDI, Mrs.S.S.Jogdand 3
COURSE OUTCOMES
PCP,NIGDI, Mrs.S.S.Jogdand 4
Unit- I
Database System Concept
PCP,NIGDI, Mrs.S.S.Jogdand 5
Concept of Data,Database,DBMS
Definition
•Data is nothing but facts and figures that can be recorded in system and have
some special meaning assigned to it.
•In the context of computer science, it refers to information that has been
translated into a form that is efficient for movement or processing.
•For example- name, age, address, account _no. etc,
PCP,NIGDI, Mrs.S.S.Jogdand 6
•Definition:-
Database: The collection of interrelated data or information relevant to an any
enterprise is called as Database .
Database Management System (DBMS) is a collection of interrelated data and set
of programs to access those data. DBMS provides a way to store and retrieve database
information that is both convenient and efficient.
•It allowing users to store, process and analyze data easily. DBMS also provides
protection and security to the databases. It also maintains data consistency in case of
multiple users.
•DBMS provides us with an interface or a tool, to perform various operations like creating
database, storing data in it, updating data, creating tables in the database and a lot more.
•Here are some examples of popular DBMS used these days:
MySQL
Oracle
IBM DB2
PostgreSQL
MongoDB
Hadoop
Amazon SimpleDB (cloud based) etc.
PCP,NIGDI, Mrs.S.S.Jogdand 7
File Processing System
PCP,NIGDI, Mrs.S.S.Jogdand 8
Disadvantage of File System
• Data Redundancy
• Data Inconsistency
• Limited Concurrency
• Poor Security
PCP,NIGDI, Mrs.S.S.Jogdand 9
Advantages of DBMS over file System –
•Avoiding Inconsistency
•Transactional Support
•Maintaining Integrity
•Enforcement of Security
PCP,NIGDI, Mrs.S.S.Jogdand 10
Applications of Database
• Railway Reservation System
•Banking
•Online Shoppings
PCP,NIGDI, Mrs.S.S.Jogdand 12
•1. Physical Level
PCP,NIGDI, Mrs.S.S.Jogdand 13
•2. Conceptual Level
•Conceptual level describes the structure of the whole database for a group of
users.
•It is also called as the data model.
•Conceptual schema is a representation of the entire content of the database.
•These schema contains all the information to build relevant external records.
•It hides the internal details of physical storage.
PCP,NIGDI, Mrs.S.S.Jogdand 14
1.3 Data Abstraction
•Database systems are made-up of complex data structures. To ease the user
interaction with database, the developers hide internal irrelevant details
from users. This process of hiding irrelevant details from user is called data
abstraction.
PCP,NIGDI, Mrs.S.S.Jogdand 15
Three levels of Data Abstraction:
•Physical level: This is the lowest level of data abstraction. It describes how
data is actually stored in database. You can get the complex data structure
details at this level.
•Logical level: This is the middle level of 3-level data abstraction architecture.
It describes what data is stored in database.
•At view level, user just interact with system with the help of GUI and enter the
details at the screen, they are not aware of how the data is stored and what
data is stored; such details are hidden from them.
PCP,NIGDI, Mrs.S.S.Jogdand 16
Instance and Schema in DBMS
•Definition of schema: Design of a database is called the schema. Schema can
be changed infrequently as information is inserted and deleted.
• Database system have three types of schema - Physical schema, logical
schema and view schema.
•The design of a database at physical level is called physical schema, how the
data stored in blocks of storage is described at this level.
PCP,NIGDI, Mrs.S.S.Jogdand 17
•Definition of instance: The data stored in database at a particular
moment of time is called instance of database.
PCP,NIGDI, Mrs.S.S.Jogdand 18
Data Independence
•Definition-The ability to modify a schema definition in one level without
affecting a schema definition in a higher level is called Data Independence.
PCP,NIGDI, Mrs.S.S.Jogdand 20
Components of DBMS are broadly classified as follows :
1.Users:
(a)Naïve User
(b)Application User
(c)Sophisticated User
(d)Database Administrator
2. Query Processor :
(a) DML Compiler
(b) Embedded DML pre-compiler
(c) DDL Interpreter
(d) Query Evaluation Engine
3. Storage Manager :
(a) Authorization and Integrity Manager
(b) Transaction Manager
(c) File Manager
(d) Buffer Manager
4. Data Structure :
(a) Data Files
(b) Data Dictionary
(c) Indices 21
(d) Statistical Data
1. Query Processor Components :
• DML Pre-compiler : It translates DML statements in a query
language into low level instructions that query evaluation engine
understands. It also attempts to transform user's request into an
equivalent but more efficient form.
b) 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
c) Physical Data Models – These models describe data at the lowest level of
abstraction. 24
PCP,NIGDI, Mrs.S.S.Jogdand
Hierarchical model
• A hierarchical data model is a data model which the data is
organized into a tree like structure.
•The structure allows repeating information using parent/child
relationships: each parent can have many children but each child
only has one parent. All attributes of a specific record are listed
under an entity type
•This model was primarily used by IBM’s Information
Management Systems in the 60s and 70s, but they are rarely seen
today due to certain operational inefficiencies.
PCP,NIGDI, Mrs.S.S.Jogdand 26
Fig: Network Data Model
Relational Data Model
• The most common model, the relational model sorts data into tables, also
known as relations, each of which consists of columns and rows. Each
column lists an attribute of the entity in question, such as price, zip code, or
birth date. Together, the attributes in a relation are called a domain. A
particular attribute or combination of attributes is chosen as a primary key that
can be referred to in other tables, when it’s called a foreign key.
• Each row, also called a tuple, includes data about a specific instance of the
entity in question, such as a particular employee.
• The model also accounts for the types of relationships between those tables,
including one-to-one, one-to-many, and many-to-many relationships.
PCP,NIGDI, Mrs.S.S.Jogdand 27
Fig: Relational Data Model
PCP,NIGDI, Mrs.S.S.Jogdand 28
1.6 Data Modelling Using E-R model
PCP,NIGDI, Mrs.S.S.Jogdand 29
Entity
•An entity can be a real-world object, either animate or
inanimate, that can be easily identifiable.
•For example, in a school database, students, teachers, classes,
and courses offered can be considered as entities. All these
entities have some attributes or properties that give them their
identity.
PCP,NIGDI, Mrs.S.S.Jogdand 30
ER Diagrams Symbols, And Notations
PCP,NIGDI, Mrs.S.S.Jogdand 31
Strong Entity
• Strong Entity:-The Strong Entity is the one whose existence does not
depend on the existence of any other entity in a schema.
•It is denoted by a single rectangle.
• A strong entity always has the primary key in the set of attributes
that describes the strong entity.
•It indicates that each entity in a strong entity set can be uniquely
identified.
•Set of similar types of strong entities together forms the Strong Entity
Set. A strong entity holds the relationship with the weak entity via an
Identifying Relationship, which is denoted by double diamond in the
ER diagram. On the other hands, the relationship between two strong
entities is denoted by a single diamond and it is simply called as a
relationship.
PCP,NIGDI, Mrs.S.S.Jogdand 32
•Let us understand this concept with the help of an example; a
customer borrows a loan. Here we have two entities first a customer
entity, and second a loan entity.
Fig: ERD
PCP,NIGDI, Mrs.S.S.Jogdand 33
Weak entity
•
Weak entity is the one that depends on its owner entity ( i.e. a strong
entity) for its existence.
• An entity that does not have a primary key is referred to as a weak entity .
• Weak entity do not have the primary key instead it has a partial key.
• Partial Key: Specifies a key that is only partially unique. Used for weak
entities that uniquely discriminates the weak entities.
• The collection of similar weak entities is called Weak Entity Set. The
relationship between a weak entity and a strong entity is always denoted with
an Identifying Relationship i.e. double diamond.
PCP,NIGDI, Mrs.S.S.Jogdand 34
Comparison
ASIS FOR COMPARISON STRONG ENTITY WEAK ENTITY
Entity
PCP,NIGDI, Mrs.S.S.Jogdand 36
Entities can be characterized into two types:
•Strong entity: A strong entity has a primary key attribute which
uniquely identifies each entity. Symbol of strong entity is same as
an entity.
Strong Entity
Weak entity: A weak entity does not have a primary key
attribute and depends on other entity via a foreign key attribute.
PCP,NIGDI, Mrs.S.S.Jogdand 37
Attributes
•There exists a domain or range of values that can be assigned to attributes. For
example, a car name cannot be a numeric value. It has to be alphabetic. A s car
registration nocannot be negative, etc.
Types of Attributes
Simple attribute − Simple attributes are atomic values, which cannot be
divided further. For example, a student's phone number is an atomic value of
10 digits.
PCP,NIGDI, Mrs.S.S.Jogdand 38
•Composite attribute − Composite attributes
are made of more than one simple attribute.
• For example, a student's complete name may
have first_name and last_name.
•Derived attribute − Derived attributes are the attributes that do not exist in
the physical database, but their values are derived from other attributes present
in the database. For example, average_salary in a department should not be
saved directly in the database, instead it can be derived. For another example,
age can be derived from data_of_birth.
PCP,NIGDI, Mrs.S.S.Jogdand 39
• Single-value attribute − Single-value attributes contain single value. For
example − Social_Security_Number.
PCP,NIGDI, Mrs.S.S.Jogdand 40
* Entity-Set and Keys:
Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a relationship
too can have attributes. These attributes are called descriptive attributes.
Degree of Relationship
The number of participating entities in a relationship defines the degree of the relationship.
Binary = degree 2 Ternary = degree 3 n-ary = degree
PCP,NIGDI, Mrs.S.S.Jogdand 42
E-R Diagram
PCP,NIGDI, Mrs.S.S.Jogdand 43
* 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 entity from entity set A can be associated with at most one entity
of entity set B and vice versa.
PCP,NIGDI, Mrs.S.S.Jogdand 44
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.
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 set A
PCP,NIGDI, Mrs.S.S.Jogdand 45
Many-to-many − One entity from A can be associated with more than
one entity from B and vice versa.
PCP,NIGDI, Mrs.S.S.Jogdand 46
•Binary Relationship and Cardinality
-A relationship where two entities are participating is called a binary relationship.
Cardinality is the number of instance of an entity from a relation that can be
associated with the relation.
1. One-to-one − When only one instance of an entity is associated with the
relationship, it is marked as '1:1'. The following image reflects that only one
instance of each entity should be associated with the relationship. It depicts
one-to-one relationship.
PCP,NIGDI, Mrs.S.S.Jogdand 47
Many-to-one − When more than one instance of entity is associated with the
relationship, it is marked as 'N:1'. The following image reflects that more than one
instance of an entity on the left and only one instance of an entity on the right can be
associated with the relationship. It depicts many-to-one relationship.
Many-to-many − The following image reflects that more than one instance of an
entity on the left and more than one instance of an entity on the right can be
associated with the relationship. It depicts many-to-many relationship
PCP,NIGDI, Mrs.S.S.Jogdand 48
E-R diagram for library management system
PCP,NIGDI, Mrs.S.S.Jogdand 49
E-R diagram for bank management system
PCP,NIGDI, Mrs.S.S.Jogdand 50