DBMS Unit 2
DBMS Unit 2
Prerequisites :
Fundamentals of Programming
Course Objectives:
To understand the fundamental concepts of database management
To provide a strong formal foundation in database concepts, technology
To give systematic database design approaches covering conceptual design, logical design
and an overview of physical design
To learn basic issues of transaction management and concurrency control
To learn and understand various Database Architectures and Applications
To learn a powerful, flexible and scalable general-purpose database to handle big data
Course Outcomes:
Demonstrate programming fundamental using python language.
Apply object-oriented programming concept using python language.
Make use of data structure and algorithm using python language.
Build MYSQL database connectivity with python for Database navigation operations
such as select, create, insert, delete, update.
Demonstrate programming fundamental using python language.
Units:
Unit I: Introduction to DBMS
Unit II: Relational Algebra, SQL and PL/SQL
Unit III: Relational Database Design
Unit IV: Database Transactions and Query Processing
Unit V: Database architecture
Unit VI: Advances in Databases and Big Data
Units:
Unit I: Introduction to DBMS
Introduction to Database Management Systems, Advantages of a DBMS
overfile-processing Systems, Database-System purpose and applications,
Levels of Database Systems, Database Languages, Data Models, Components
of a DBMS and overall structure of a DBMS, Database Design and ER Model:
Entity, Attributes, Relationships, Constraints, types of Keys, Design Process,
Entity Relationship Model, ER Diagram, Design Issues, Extended E-R Features,
converting E-R & EER diagram into tables.
Introduction to DBMS:
What is DBMS
Why DBMS
Advantages of a DBMS overfile-processing Systems
What is DBMS?
5 ABC Pune 19
Table
9 XYZ Pune 18
3 LMN Pune 19
Database:
- Database can be access at different levels with their own customized front-end
application.
- The rows are called Tuple or Record and the columns are called Domain or Attribute.
Note : The data items within one row may belong to different data types.
All the data items within a single columns are of the same data type.
Database-management system (DBMS):
All these issues can be resolved by having some kind of rules to maintain the integrity of
the database.
Purpose Of DBMS
- DBMS helps users to create, insert, retrieve and update the information contained in the
database as per the requirement .
Back-end : it can be called as server side, it provides data on request and it also contains
the database.
front-end and back-end
Back-end Tools :
Databases like Oracle, Microsoft SQL Server, IBM DB2, MySQL, NoSQL and PostgreSQL
useful to develop backend
Levels of Database Systems
Levels of Database Systems
Physical Level :
The lowest level of abstraction describes how the data are actually stored.
It also describes complex low-level data structures in detail.
In this level data is stored in the external hard drives i.e. data is stored in files and folders.
Actual physical storage structure and access paths can be describe with the help of this level.
Levels of Database Systems
Conceptual Level :
It is the next-higher level of abstraction describes what data are stored in the database
It describes how the database appears to the users conceptually and the relationships between various
data tables.
The highest level of abstraction describes only part of the entire database.
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.
Data models define how data is connected to each other and how they are processed and stored inside the
system.
A Data model provides a way to describe the design of a database at the physical, logical, and view levels.
This model uses tables for representing data and in-between relationships.
This model uses a collection of tables to represent data as well as the relationships among those data.
Each table has multiple columns, and each column has a unique name.
Each table contains records of a particular type with fixed number of fields, or attributes.
The relational data model is the most widely used data model
5 ABC A
Stud Nam City Age
_id e 9 XYZ B
3 LMN A
5 ABC Pune 19
9 XYZ Pune 18 DIV Year
3 LMN Mumb 19
ai A FY
B SY
A SY
Database
5 ABC A
A FY
9 XYZ B B SY
3 LMN A A SY
Database
5 ABC A FY
9 XYZ B SY
3 LMN A SY
Entity-Relationship Data Model
An ER model is the logical representation of data as objects and relationships among them.
These objects are known as entities, and relationship is an association among these entities.
The entity-relationship (E-R) data model uses a collection of basic objects, called entities, and relationships among
these objects.
Object-based Data Model
It is an extension of the ER model with notions of functions, encapsulation, and object identity, as well.
This model supports a rich type system that includes structured and collection types.
object-oriented data model that can be called as extending the E-R model as it contains encapsulation,methods
and identity of object.
Combination of object-oriented data model and relational data model called object- relational data model.
Semistructured Data Model
Semi-structured data model consist of specification of data where individual data items of the same type may have
different sets of attributes.
Software
Hardware
Procedures
Data
Users
Components of DBMS
Software :
Software in DBMS is used to store, retrieve, and update data in the database.
Software is capable of understanding the database language and which runs the commands into the
database.
Components of DBMS
Hardware :
Hardware components includes computer, I/O channels for data, hard disks.
Hardware components is mainly used for keeping and storing the data in the database.
Components of DBMS
Procedures :
This component consist of set of instructions and rules to apply a database management system
It also consists methods to setup to login logout of the DBMS, maintain backups, handle database
and also to guide users for operating the databases, etc.
Components of DBMS
Data :
Important task of DBMS is to process the data, in DBMS data is stored, retrieved, and updated to and from the
databases.
Components of DBMS
Users :
End-Users : who interact with the DBMS to perform various operations using the different types of
commands such as insert, update, retrieve, and delete, etc.
Database Design – (ER) Modeling
Below mentioned are the Database Design Techniques.
ER Modeling
Normalization
ER Modeling
ER model : Entity-Relationship model.
It is a technique for organizing the data independent of the actual database implementation
ER model is used to define the data elements and relationship for a specified system.
ER model very simple and easy to design view of data can develop.
Entity
Entity :
Student
Entity
Entity instance :
Regular Entity :
Weak entity :
Attribute
Key attribute
The attribute which uniquely identifies every entity instance is called key attribute
Student_id
Simple attribute
The attribute that can not be divided into simpler components is called Simple attribute.
Address
City State
Single valued Attributes
The Attribute that can take only a single value for each entity instance called as Single
valued attribute
The attribute that can take more than one value for each entity instance called as multi-
valued attribute.
When value of an attribute can be calculated based on other attributes is called derived
attribute.
For Example : Student_age can be calculated from DOB and Current date
Relationships
Relation of Weak Entity with other entities can be represent with the help of below
mentioned symbol
Relationships
Relation of Weak Entity with other entities can be represent with the help of below
mentioned symbol
Cardinality of a Relationship
For Example : One faculty works in only one college But one college can
have many faculties. Hence it is Many-to-One relationship.
Cardinality of a Relationship
Many to One relationship in ER modeling
Cardinality of a Relationship
Many to Many relationship
For Example : One student can select multiple subject and One subjects can be enrolled
by many students.
Hence it is a M:N relationship and cardinality is Many-to-Many
Cardinality of a Relationship
Many to Many relationship in ER modeling
Relationship Participation
Relationship Participation
1. Total
In this type of participation each entity instance will be connected through each entity instance through the
relationship.
2. Partial
Advantages :
Disadvantages :
- Constraints plays important role to ensure the correctness of data in the database
Domain Constraint
Key Constraint
Entity Integrity Contstraint
Referential Intergrity Constraint
Domain Constraint
- It defines valid set of values or domain values for an attribute and the value of the attribute
must be available in the corresponding domain.
- For Example :
Stud_id Name City Age
In Name Column values “ 33 ”
Not allowed as it is integer value 5 ABC Pune 19
And name is string value.
9 XYZ Pune 18
3 33 Pune 19
Key Constraint
- To identify an entity uniquely from entity set of entity, keys are the entity set which are used.
- Multiple keys can be available with entity set.
- Primary key must be unique
Table 1 Table 2
- As the use of primary key value is to identify individual record, if the primary key contains NULL
value, then we can't identify those records.
Stud_id Name City Age Does not satisfy the entity integrity constraint
5 ABC Pune 19
9 XYZ Pune 18
LMN Pune 19
NULL
Referential Integrity Constraint
- It says that if a foreign key in Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key
in Table 1 must be null or be available in Table 2.
Referential Integrity Constraint
2 XYZ B 2
3 LMN B 5
Relationship
2 Computer VIIT
3 IT VIIT
Keys
- Key can also used to establish and identify relationships between tables.
Keys
Types of key:
- Primary key
- Candidate key
- Super Key
- Foreign key
Keys : Primary Key
Primary key :
- Table can have multiple keys, the key which is most suitable from those lists become a primary key.
- The candidate key can having only one attribute or composite as well.
For example :
- In Super key there is no restriction on number of attributes, it may consist of any number of attributes
For example :
Super Key
Stud_id Name PRN Aadhar Age
Number
1 Prashant 121 4****9 19
2 Ritesh 122 4****3 18
3 Vivek 123 4****5 21
4 Prashant 124 4****6 25
5 Rahul 125 4****7 23
Keys : Foreign Key
Foreign key :
- To point to the primary key of another table foreign key columns are used.
2 XYZ B 2
3 LMN B 3
Relationship
2 Computer VIIT
3 IT VIIT
Keys : Alternate Key
Alternate key :
Those candidate keys which are not the Primary key are Alternate keys.
Design Process
It provide the technical drawing of how the data is going to be stored in a system.
Design process provides clear idea about the behavior of any application
Life Cycle
- Requirement Analysis :
- Planning : based on basic requirements which defines boundaries and scope of database
- Database Designing :
- Splitting into various models
Physical Model
Logical Model : It is paper work, actual implementation of database not required
- Implementation
- behavior of the application based on the requirements
- Data conversion and loading
- Testing
Design Process
- Accuracy of Data
Aggregation.
Extended Entity-Relationship (EE-R)
Sub classes are the group of entities consist of some unique attributes.
Sub class inherits the properties and attributes from super class.
Super class Department has sub groups: AInDS, Computer and IT.
Extended Entity-Relationship (EE-R)
Generalization
- By identifying common attributes from a set of entities, a generalized entity can be created.
- Two or more entities can be generalized to a higher level entity, if these entities have some
attributes in common.
Extended Entity-Relationship (EE-R)
Generalization
Extended Entity-Relationship (EE-R)
Specialization
- In this process higher level entity can be specialized into two or more entities.
Extended Entity-Relationship (EE-R)
Specialization
Extended Entity-Relationship (EE-R)
- Category or Union
- This type consist of relationship of one super or sub class with more than one super class.
Extended Entity-Relationship (EE-R)
Category or Union
Extended Entity-Relationship (EE-R)
Aggregation
- In the case of E-R diagram it is not possible to represent relationship between as entity and a
relationship.
- With the help of aggregation relationship with its corresponding entities is aggregated into a higher
level entity.
Extended Entity-Relationship (EE-R)
Aggregation
References
https://www.conceptatech.com
https://www.javatpoint.com
https://www.tutorialspoint.com
https://www.guru99.com
https://www.gatevidyalay.com
https://www.geeksforgeeks.org