DBMS Notes
DBMS Notes
Components of DBMS
Component Description
DBMS NOTES 1
of files. This led to:
Duplication of data
Inconsistency
Waste of space
Applications of DBMS
Banking: maintaining customer information, accounts, loans, and banking
transactions
Advantages of DBMS
Reduction in Data Redundancy: eliminates duplication of data, reducing waste
of space
DBMS NOTES 2
Improvement in Data Security: provides a centralized system for security
checks and enforcement
Efficient System:
It is very common to change the content of stored data. These changes
can easily be made in a database management system than in a
conventional system as these do not need to have any impact on
application programs. The cost of developing and maintaining systems is
also lower.
Disadvantages of DBMS 🚨
Problems associated with Centralization
"Centralization increases the security problems and disruption
due to downtime and failures."
DBMS NOTES 3
failure,
the data can be recovered."
Other Disadvantages
Atomicity and integrating problems are found.
📁
Advantages and Disadvantages of File-Based Systems
DBMS NOTES 4
Data redundancy: Since these systems used a decentralized approach,
so each department used its own application programs and files.
Security Problems
Who is a DBA? 🤔
A Database Administrator (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.
Role of DBA
Defining conceptual schema: A DBA creates the conceptual schema
corresponding to the abstract level database design made by data
administrator.
DBMS NOTES 5
can access the database.
Granting access to users: A DBA regulates the usage of specific parts of the
database by various users.
Database Models 📚
A database model is a collection of conceptual
tools for describing data, data relationships, data semantics, and
consistency constraints.
DBMS NOTES 6
Organises data in a tree structure, with each child node having only one
Hierarchical
parent node
Organises data into tables with rows and columns, with each row
Relational
representing a single record
Object-
Uses objects to represent data and relationships between them
Oriented
Relations (Tables)
DBMS NOTES 7
A relation (table) consists of rows (records) and columns (fields).
Table Structure:
Column Description
Operations
Three basic operations are used to develop useful sets of data:
Projection: Extracts fields from a table, allowing the user to create new tables
that contain only the required information.
DBMS NOTES 8
Object-Oriented Database Structure
The class population is the root of a class
hierarchy, which includes the Nation class. The Population class is also
the root of two sub-classes: Men and Women.
Class Hierarchy:
Class Description
Instance:
Types of Schema
There are three types of schema:
DBMS NOTES 9
Conceptual Schema: Describes the stored data in terms of the data model of
the DBMS.
📈 Data Independence 💻
Definition:
HASA relationship: a relationship between two entities where one has or owns
the other
Relationship Type
A set of meaningful associations between one or more participating entity types.
Relationships with the same attributes fall into one relationship set.
DBMS NOTES 10
Degree of a Relationship
Defined as the number of entities associated with the relationship.
Degree Description
Connectivity or Cardinality 💻
Describes the mapping of associated entity instances in a relationship.
Attributes 📊
Define the properties of a data object in an entity.
📜
the value of related attributes or a set of attributes
DBMS NOTES 11
Entity Set 📜
Weak Entity Set: an entity set that does not possess sufficient attributes to
form a primary key
Mapping Constraints 🗂️
One-to-One: an entity in A is associated with at most one entity in B, and an
entity in B is associated with at most one entity in A
Specialization
DBMS NOTES 12
Aggregation
Let me know if you need anything else! 😊## Generalization and Specialization 📈
Generalization
is a top-down process of defining super-classes and their related
sub-classes. We first define a super-class, then sub-classes, and their
attributes and relationships.
Advantages of Generalization:
Enables the entity type to share common attributes among different classes
Allows for the creation of a class that can be refined progressively into finer
sub-classes
Inheritance 💻
Inheritance is the process by which one class acquires the
properties of one or more other objects.
Key Points:
A class can be created at a broad level and then refined progressively into
finer sub-classes
DBMS NOTES 13
An entity type that includes distinct subclasses that share common attributes
Can be created at a broad level and then refined progressively into finer sub-
classes
Subclass:
Inherits all the properties of its superclass to which it can add its own
properties
Examples:
Superclass Subclass Unique Attributes
E-R Diagrams 📊
Banking System:
class Bank {
accounts: [
{
accountNumber: string,
accountHolder: string,
balance: number
}
]
}
class Account {
transactions: [
{
DBMS NOTES 14
transactionId: string,
transactionDate: date,
amount: number
}
]
}
Hospital System:
class Hospital {
patients: [
{
patientId: string,
patientName: string,
address: string
}
]
}
class Patient {
appointments: [
{
appointmentId: string,
appointmentDate: date,
doctor: string
}
]
}
DBMS NOTES 15
Simpllicity
Data sharing
Data security
Data integrity
Efficiency
Disadvantages:
Implementation complexity
Inflexibility
Operational anomalies
Network Model
Advantages:
Simplicity
Database standards
Disadvantages:
System complexity
Operational anomalies
Not user-friendly
Relational Model
Advantages:
Simplicity
No anomalies
Structural independence
DBMS NOTES 16
Easier design, implementation, maintenance, and usage
Disadvantages:
Hardware overheads
Database Users 👥
There are different types of users depending on their need and way of accessing
the database:
Application Programmers:
They are the developers who interact with the database by means of DML
queries. These queries are written in the application programs like C,
C++; Java, etc.
DBMS NOTES 17
Specialized Users: These users are also sophisticated users, but they write
special database application programs.
Stand-alone Users: These users will have standalone databases designed for
a specific purpose.
Native Users: These are the users who use the existing applications and
interfaces.
File Organization 💻
File Organization: A file organization refers to the way the files are physically
arranged on a storage device.
Indexed Sequential File An effective way of organizing the records when there is a
Organization need to access individual records directly.
Convenience of updates
Ease of retrieval
Reliability
Security
Integrity
Advantages:
Easy to handle
Involves no overhead
Disadvantages:
Advantages:
DBMS NOTES 19
Supports updation operation in place
Disadvantages:
Disadvantages:
🔑
DBMS NOTES 20
Multi-Key File Organization 🔑
Definition:
A multi-key file organization is a method of organizing files to
support multiple keys or access paths. It allows for efficient retrieval
of records based on different keys or combinations of keys.
Example:
Consider a banking system with several types of users, including
tellers, loan officers, branch managers, and account holders. Each user
needs to access the same data in different ways. A multi-key file
organization can support multiple access paths, including account ID,
overdraft limit, social security number, and group code.
Approach:
One approach to support multi-key file organization is to use a single
data file and multiple indexes, each providing a different access path
to the data records.
Hashing 🎯
Definition:
Hashing is a technique of storing and retrieving records in a file
using a hash function. The hash function calculates the address of the
page where the record is stored based on one or more fields in the
record.
Hash Function:
A hash function is a mathematical formula that manipulates the keys in
some way to compute the index for the keys in the hash table.
Example:
Consider a hash function that takes the first two characters of the
staff number, converts them to an integer value, and then adds this
value to the remaining digits of the field. The resulting sum is used as
the address of the disk page where the record is stored.
Collision Resolution:
DBMS NOTES 21
Open Addressing: A technique of resolving collisions by probing other slots in
the hash table to find an empty slot.
Open Addressing Probes other slots in the hash table to find an empty slot
Chained Overflow Stores multiple records with the same hash value in a linked list
Separate Chaining Uses a linked list to store all records with the same hash value
Initial State:
T0 | T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8
---| ---| ---| ---| ---| ---| ---| ---| ---
null | null | null | null | null | null | null | null | nul
l
Insertion of Elements:
h(5) = 5 mod 9 = 5
h(28) = 28 mod 9 = 1
h(19) = 19 mod 9 = 1
...
T0 | T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8
---| ---| ---| ---| ---| ---| ---| ---| ---
DBMS NOTES 22
null | 28 -> 19 | null | null | null | 5 | null | null | nu
ll
🗂️
| null | null
```## Collision Resolution by Open Addressing
**Example:** Consider inserting the keys 16, 26, 37, 59, 21,
65, 88 into a hash table of size m = 11 using linear probing.
DBMS NOTES 23
| 65 | 10 | 0 | 1 |
| 88 | 0 | 1 | 2 |
**Example:** Consider inserting the keys 76, 26, 37, 59, 21,
65, 88 into a hash table of size m = 11 using quadratic probi
ng with c1 = 1 and c2 = 3.
DBMS NOTES 24
where m is the size of the hash table, k is the key, and h1 a
nd h2 are two auxiliary hash functions.
**Example:** Consider inserting the keys 76, 26, 37, 59, 21,
65, 88 into a hash table of size m = 11 using double hashing
with h1(k) = k mod 11 and h2(k) = k mod 9.
## B-Tree 🌳
A B-tree of order m can be defined as an m-way search tree th
at satisfies the following properties:
**Advantages:**
DBMS NOTES 25
* B-tree is perfectly balanced, so the number of nodes access
ed to find a key becomes less.
* B-tree avoids waste of storage space since any node (except
the root) is at least half full.
**Example:**
🌳
| 5 | 3 | 5 |
| ... | ... | ... |## B-Trees
DBMS NOTES 26
### Example of a B-Tree of Order 5
```js
+---------------+
| 40 |
+---------------+
| / \ |
|/ \ |
+---------------+---------------+
| 14 | 68 |
+---------------+---------------+
| / \ / \ / \ |
|/ \| |/ \| |/ \|
+---------------+---------------+---------------+
| 5 | 15 | 35 | 45 | 55 |
+---------------+---------------+---------------+
B+ Trees 🌳
A B+ tree is a variation of a B-tree that is well-suited for disk access.
Properties of B+ Trees
Internal Nodes: Store only keys and child pointers.
Example of a B+ Tree
+---------------+
| 40 |
+---------------+
| / \ |
|/ \ |
+---------------+---------------+
DBMS NOTES 27
| 14 | 68 |
+---------------+---------------+
| / \ / \ / \ |
|/ \| |/ \| |/ \|
+---------------+---------------+---------------+
| Data | Data | Data | Data | Data |
+---------------+---------------+---------------+
📊
Relational Database Management Systems (RDBMS)
Column Values are of the Same Kind: All values in a column come from the
same domain.
RDBMS vs DBMS
RDBMS DBMS
Relationship between
Specified at table creation Programmatically specified
tables
DBMS NOTES 28
Security Multiple levels of security Tight security
Codd's 12 Rules 📜
Dr. E.F. Codd's 12 rules for a Relational Database Management System (RDBMS):
DBMS NOTES 29
Rule 12: Non-subversion rule
DBMS NOTES 30