DBMS 2
DBMS 2
Components of DBMS 🗂️
The components of DBMS are:
DBMS 2 1
Component Description
3. The data manager requests for specific records from the file manager.
4. The file manager requests for specific blocks from the disk manager.
5. The disk manager retrieves the block and sends it to the file manager.
6. The file manager sends the required record to the data manager.
Applications of DBMS 📈
The applications of DBMS are:
DBMS 2 2
Finance: storing information about holidays, sales, and purchases of financial
instruments
Advantages of DBMS 🎉
The advantages of DBMS are:
Sharing of data
Enforcement of standards
Note: This study guide is designed to be appended to other study guides, and the
format is optimized for readability and aesthetics.## Database Management
System 📊
Availability of Up-to-Date Information: A DBMS improves the availability of up-to-
date information since the data can be shared and the DBMS makes it easy to
respond to unforeseen information requests.
Disadvantages of DBMS 🚫
Problems associated with Centralization: Centralization increases security
problems and disruption due to downtime and failures.
DBMS 2 3
Complexity of Backup and Recovery: DBMS provides centralization of the
data, which requires adequate backups of the data so that in case of failure,
the data can be recovered.
📁
Advantages and Disadvantages of File-Based System
Poor data control: There was no centralized control on the fields, making field
names ambiguous and having many meanings.
DBMS 2 4
capabilities quite low.
Security problems: It was difficult to enforce security systems, and every user
of the database system should not be allowed to access all data.
Who is DBA? 🤝
Database Administrator (DBA): A DBA is an individual person or a group of
persons with an overview of one or more databases so that he/she can control the
design and the use of these databases. A DBA provides the necessary technical
support for implementing policy decisions of databases.
Role of DBA:
4. Giving backup and recovery strategies: A DBA must define and implement an
appropriate periodical recovery strategy to recover the database from all
types of failures.
5. Granting access to users: A DBA regulates the usage of specific parts of the
database by various users.
DBMS 2 5
3. Support of multiple views of data: A database system supports multiple views
of data.
Database Models 📊
Hierarchical Database Model:
DBMS 2 6
Relational Database Management System (RDBMS) is based on the relational
model developed by E.F. Codd. A relational database represents all data in the
database as simple two-dimensional tables called relations.
Key Components
Relations: Represented as tables, each row (record) represents a data entity
with columns representing attributes (fields).
Tuple: Each row in a relational table, which must have a unique primary key.
Operations
Selection: Retrieves certain records from a table based on user-specified
criteria.
Projection: Extracts fields from a table, allowing users to create new tables
with only required information.
Join: Combines data from multiple tables, relating them based on common
attributes.
Relational Algebra
These three operations are used to develop useful sets of data and are called
📈
relational algebra.
DBMS 2 7
Object-Oriented Database Model 📈
Object-oriented databases store and maintain objects, which contain both data
and procedures that manipulate the data.
Key Components
Class: A blueprint for creating objects.
Inheritance: A class can inherit attributes and methods from another class.
Instances
Types of Schemas
DBMS 2 8
Physical Schema: Describes the database design at the physical level,
including storage details.
Conceptual Schema: Describes the stored data in terms of the data model of
the DBMS.
Data Independence 📈
Definition
Types
Physical Data Independence: Modification at the physical level without
affecting the conceptual schema.
ER Model 📊
Definition
Key Components
Entity: A thing of interest that has existence.
DBMS 2 9
Degree of Relationship: The number of entities involved in a relationship.
Degree of a Relationship
The degree of a relationship is defined as the number of entities associated with
the relationship.
Connectivity or Cardinality
The connectivity of a relationship describes the mapping of associated entity
instances in the relationship.
DBMS 2 10
One-to-Many (1:M): One instance of entity A is associated with zero, one, or
many instances of entity B.
Attributes 📝
Attributes define the characteristics of a data object of an entity.
Types of Attributes
Type Description
Single-Valued
An attribute that holds a single value for a single entity.
Attribute
Multi-Valued Attribute An attribute that holds multiple values for a single entity.
Entity Set 📁
Weak and Strong Entity Set
A weak entity set does not possess sufficient attributes to form a primary key,
while a strong entity set has a primary key.
Mapping Constraints 🗺️
Mapping constraints express the number of entities to which another entity can be
associated via a relationship set.
DBMS 2 11
Type Description
Specialization
Specialization is defined as the process of identifying subsets
of an entity (super-class or super-type) that share some
distinguishing characteristic.
Aggregation
DBMS 2 12
Example: Employee, Department → University## 📚 Inheritance and
Generalization
Inheritance is the process by which one class acquires the properties of one or
more other objects.
Generalization
Generalization is a top-down process of defining super-classes and their related
sub-classes.
A sub-class is an entity type that inherits all the properties of its super class
and can add its own properties.
Branch
Aggregation
Aggregation is the process of compiling a class from multiple objects.
DBMS 2 13
structure, whereas association and aggregation involve relationships between
objects.
Subclass
A subclass is an entity type that inherits all the properties of its super class and
can add its own properties.
Superclass Subclass
// Subclass: SavingsAccount
class SavingsAccount extends Account {
// Inherited attributes
accountNumber;
accountHolder;
// Unique attributes
DBMS 2 14
interestRate;
}
📊 E-R Diagrams
Hospital E-R Diagram
Patient Address Correspondence
Patient name
Age
Publication date
📊Models
Advantages and Disadvantages of Different
Hierarchical Model
Advantages:
Simpllicity
Data sharing
Data security
Data integrity
Efficiency
Disadvantages:
DBMS 2 15
Implementation complexity
Inflexibility
Operational anomalies
Network Model
Advantages:
Simplicity
Data sharing
Data security
Data integrity
Disadvantages:
System complexity
Operational anomalies
Not user-friendly
Relational Model
Advantages:
Simplicity
No anomalies
Structural independence
Disadvantages:
DBMS 2 16
Hardware overheads
📊 SQL Limitations 🤔
SQL does not provide an efficient way to browse alphabetically through an index.
Thus, some systems cannot provide a simple query to fetch data from the
database.
👥 Database Users 👥
Database users are the ones who really use and benefit from the database. There
are different types of users depending on their needs and ways of accessing the
database.
1. Application Programmers 💻
They are developers who interact with the database by means of DML queries.
These queries are written in application programs like C, C++, Java, etc.
2. Sophisticated Users 🤓
They are database developers who can write complex SQL applications.
They interact with the database directly by means of query language SQL.
DBMS 2 17
These users will be scientists, engineers, analysts who thoroughly study SQL
and DBMS to apply the concepts in their requirement.
3. Specialized Users 🎯
They are also sophisticated users, but they write special database application
programs.
They are the developers who develop complex programs to meet specific
requirements.
4. Stand-alone Users 📊
They have standalone databases that are designed for a specific purpose.
5. Native Users 🌟
They are users who use existing application programs that interact with the
database.
They do not directly interact with the database but use the application
programs to access the database.
📁 File Organization 📁
A file organization refers to the way the files are physically arranged on a storage
device.
Sequential File Records are written one after another in the order they are
Organization created, and can be accessed only in that order.
DBMS 2 18
Indexed Sequential File An effective way of organizing records when there is a large
Organization number of records and frequent updates.
Convenience of updates
Ease of retrieval
Reliability
Security
Benefits
Records can be accessed sequentially and directly
Drawbacks
Can only be stored on disks
DBMS 2 19
Challenges
Duplication of data is not desirable
Solution
A multi-key file that uses indexes provides an efficient solution to this retrieval
problem. A single data file and a set of indexes provide different access paths to
data records of the file.
Hashing 🤔
Definition
A hash function is a mathematical formula that manipulates the
keys in some form to compute the index for that key in the hash
table.
Division-remainder hashing: uses the MOD function, which takes the field
value, divides it by some predetermined integer value, and uses the remainder
of this division as the disk address.
Collision Management ⚠️
DBMS 2 20
A collision is a process that occurs when more than one key maps to the same
slot in the hash table.
Open addressing
0 NULL
1 19 19 → 28
2 20 20
3 NULL
4 5 5
5 NULL
6 15 15 → 33
7 NULL
8 17 17 → 10 → 12
Note: The slots contain pointers to the head of the linked list of all elements that
hash to the same value.## Collision Resolution by Open Addressing 🤔
Collision resolution by open addressing is a technique used in hash tables to
handle collisions, which occur when two different keys hash to the same index.
Linear Probing 🔍
Linear probing is a method of collision resolution that uses the following hash
function:
h(i) = (k mod m + i) mod m
where m is the size of the hash table, k is the key, and i is the probe number.
DBMS 2 21
Example: Consider inserting the keys 76, 26, 37, 59, 21, 65, and 88 into a hash
table of size m = 11 using linear probing.
76 10 0 10
26 4 0 4
37 4 1 5
59 4 2 6
21 10 1 0
65 10 2 1
88 0 2 2
Index Key
0 21
1 65
2 88
4 26
5 37
6 59
10 76
Quadratic Probing 🔍
Quadratic probing is another method of collision resolution that uses the following
hash function:
h(i) = (k mod m + ci + di^2) mod m
where m is the size of the hash table, k is the key, ci and di are constants, and i is
the probe number.
DBMS 2 22
Example: Consider inserting the keys 76, 26, 37, 59, 21, 65, and 88 into a hash
table of size m = 11 using quadratic probing with c1 = 1 and c2 = 3.
76 10 0 10
26 4 0 4
37 4 1 8
59 4 2 2
21 10 1 0
65 10 2 1
88 0 2 5
Index Key
0 21
1 65
2 59
4 26
5 88
8 37
10 76
Double Hashing 🔍
Double hashing is a method of collision resolution that uses two hash functions:
h1(k) = k mod m h2(k) = k mod (m - 1)
where m is the size of the hash table, k is the key, and h1 and h2 are the two hash
functions.
The final hash value is calculated as:
h(i) = (h1(k) + i * h2(k)) mod m
DBMS 2 23
Example: Consider inserting the keys 76, 26, 37, 59, 21, 65, and 88 into a hash
table of size m = 11 using double hashing.
76 10 4 0 10
26 4 1 0 4
37 4 1 1 5
59 4 1 2 6
21 10 4 1 0
65 10 4 2 1
88 0 1 2 2
Index Key
0 21
1 65
2 88
4 26
5 37
6 59
10 76
B-Trees 🌳
A B-tree of order m is an m-way search tree that satisfies the following properties:
DBMS 2 24
have at least one key. If the root node is a non-leaf node then it
will have at least 2 children and at least one key.A non-leaf
node with n key values should have n + 1 children."
B-trees are perfectly balanced, which means that the number of nodes accessed
to find a key is minimized.## 🌳 🌳
B-Trees
Order of a B-Tree
The order of a B-Tree is the maximum number of children a node can have.
Properties of a B-Tree
Minimum Children: The minimum number of children a node can have is
⌈order/2⌉.
Maximum Children: The maximum number of children a node can have is the
order.
Variations of B-Trees
DBMS 2 25
2-3 Tree: A B-Tree of order 3.
📈 B+ Trees 📈
A variation of B-Trees, well-suited for disk access.
Linked List of Leaf Nodes: Each leaf node has a pointer to the next leaf node,
forming a linked list.
Example of a B+ Tree
_______
/ \
/ \
/ \
40 80
/ \ / \
/ \ / \
10 30 60 90
/ \ / \ / \ / \
1 5 20 35 45 55 70 85
|_____| |_____| |_____| |_____|
D1 D2 D3 D4 D5 D6 D7 D8
📚(RDBMS) 📚
Relational Database Management Systems
Definition
DBMS 2 26
A database management system that is based on the relational
model introduced by Dr. E.F. Codd.
Column Values are of the Same Kind: All values in a column come from the
same domain.
🤔 DBMS vs RDBMS 🤔
Differences
DBMS RDBMS
Client/Server
Not supported Supported
Architecture
Distributed
Not supported Supported
Databases
Each table has its own Many tables are grouped into one
Table Extensions
extension database
📝 📝
DBMS 2 27
📝 Codd's Rules 📝
A set of 12 rules for Relational Database Management Systems (RDBMS)
introduced by Dr. E.F. Codd.
DBMS 2 28