0% found this document useful (0 votes)
15 views

DBMS 2

Uploaded by

dolar45755
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

DBMS 2

Uploaded by

dolar45755
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

DBMS 2

Database and Database Management System 📊


A database is a collection of related information stored in a way that it is available
to many users for different purposes.

"A database is a logically coherent, organized collection of


similar data. Similar data refers to the collection of data, which
is stored based on the same context."

A Database Management System (DBMS) is a collection of interrelated data and


a set of programs to access those data.

"A DBMS is a software system that allows access to data


contained in the database. Its objective is to provide a
convenient and effective method of defining, storing, and
retrieving the information contained in the database."

Need for DBMS 🤔


The need for DBMS arose from the problems of traditional file-based systems,
such as:

Data redundancy and inconsistency

Difficulty in accessing and managing large amounts of data

Lack of data security and integrity

DBMS solves these problems by providing a centralized repository of data,


reducing data redundancy and inconsistency, and ensuring data security and
integrity.

Components of DBMS 🗂️
The components of DBMS are:

DBMS 2 1
Component Description

Users Application programmers, end users, and database administrators

Software DBMS, operating system, and application programs

Hardware Computers, storage devices, and input/output devices

Numerical and non-numerical data, including whole numbers, floating-


Data
point numbers, characters, and logical values

Interaction among DBMS Components 📈


The interaction among DBMS components is as follows:

1. User requests for specific information using an application program.

2. The request is processed by the DBMS data manager.

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.

7. The transaction manager supervises the data transaction.

Applications of DBMS 📈
The applications of DBMS are:

Banking: maintaining customer information, accounts, loans, and banking


transactions

Universities: maintaining student records, course registration, and grades

Railway Reservation: checking availability of reservation in different trains and


tickets

Airlines: reservation and schedule information

Telecommunication: keeping records of calls made and generating monthly


bills

DBMS 2 2
Finance: storing information about holidays, sales, and purchases of financial
instruments

Sales: customer, product, and purchase information

Advantages of DBMS 🎉
The advantages of DBMS are:

Reduction in data redundancy

Reduction in data inconsistency

Sharing of data

Enforcement of standards

Improvement in data security

Maintenance of data integrity

Better interaction with users

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.

Efficient System: A DBMS is an efficient system as changes can be easily made


to the stored data without impacting application programs.

Disadvantages of DBMS 🚫
Problems associated with Centralization: Centralization increases security
problems and disruption due to downtime and failures.

Cost of Software: The cost of software is a significant drawback, especially


for costly software.

Cost of Hardware: The cost of hardware is another major disadvantage of


DBMS.

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.

Difference between Database and File System 🤔


Database File System

Data redundancy Does not exist Exists

Data inconsistency Does not exist Exists

Accessing data Easier Comparatively difficult

Data isolation Does not exist Exists

Atomicity and integrating Not found Found

Security of data Good Not good

Concurrent Access and Crash Recovery Found Not found

📁
Advantages and Disadvantages of File-Based System

Advantages of File-Based System:

Helps in overall understanding of the complexity of database systems

Provides a useful historical perspective on how we handle data

Results in smooth transition from traditional file-based systems to newer


database systems

Disadvantages of File-Based System:

Data redundancy: Since these systems used a decentralized approach, each


department used its own application programs and files, resulting in data
redundancy or duplicacy of information.

Poor data control: There was no centralized control on the fields, making field
names ambiguous and having many meanings.

Poor data manipulation capabilities: These systems do not provide strong


connections between data in different files, making data manipulation

DBMS 2 4
capabilities quite low.

Data dependence: Files and records were described by specific physical


formats that were coded into the application programs.

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:

1. Defining conceptual schema: A DBA creates the conceptual schema


corresponding to the abstract level database design made by data
administrators.

2. Physical database design: A DBA decides how the data is to be represented


in the stored database.

3. Security and integrity checks: A DBA is responsible for providing


authorization and authentication checks so that no malicious users can access
the database.

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.

Characteristics of Database Approach 📈


1. Self-describing nature of a Database system: A database system is self-
describing, meaning it contains a description of its own structure.

2. Insulation between Programs, data and data abstraction: A database system


provides insulation between programs, data, and data abstraction.

DBMS 2 5
3. Support of multiple views of data: A database system supports multiple views
of data.

4. Sharing of Data and Multi-user Transaction Processing: A database system


allows sharing of data and multi-user transaction processing.

Database Models 📊
Hierarchical Database Model:

A hierarchical database model organizes the data in a tree


structure, where each child node can have only one parent
node, and at the top of the structure, there is a single parent
node.

Network Database Model:

A network database model allows having multiple parent nodes


for a child node, which makes it more flexible than the
hierarchical model.

Relational Database Model:

A relational database model organizes the data in tables with


well-defined schemas, which makes it easy to manage and
query the data.

Object-Oriented Database Model:

An object-oriented database model organizes the data as


objects, which can contain both data and functions that
operate on that data.## Relational Database Management
System (RDBMS) 📊

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.

Domain: The set of allowable values for each attribute.

Primary Key: A unique identifier for each tuple in a relation.

Secondary Key: A key that corresponds to a primary key in another relation,


relating tables.

Example: Book Store Database


Table Attributes

Author Author ID, Author Name, Author DOB

Publisher Publisher ID, Publisher Name, Publisher Address

Book ISBN, Author ID, Publisher ID, Date, Title

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.

Objects: Instances of classes, which contain data and procedures.

Example: Object-Oriented Database Structure


Class Attributes

Population Population ID, Name, Age

Nation Nation ID, Population ID, Reign, Continent

Country Country ID, Nation ID, Language, Currency

Object Query Language (OQL)


OQL is used to manipulate and retrieve data in object-oriented databases.

Schema and Instances 📝


Schema

The overall design of the database.

Instances

The collection of information stored in the database at a


particular moment.

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.

External Schema: Allows data access to be customized at the level of


individual users or groups of users.

Data Independence 📈
Definition

The ability to modify a schema definition in one level without


affecting a schema definition in the next higher level.

Types
Physical Data Independence: Modification at the physical level without
affecting the conceptual schema.

Logical Data Independence: Modification at the conceptual level without


affecting the external schema.

ER Model 📊
Definition

A conceptual data model that views the real world as entities


and relationships.

Key Components
Entity: A thing of interest that has existence.

Entity Type Set: A set of entities with common attributes.

Relationship: An association between two or more entities.

DBMS 2 9
Degree of Relationship: The number of entities involved in a relationship.

Attributes: Characteristics or properties of entities.

Example: ER Model for a University Database


Entity Attributes

Student Student ID, Name, Age

Course Course ID, Course Name, Credits

Enrollment Student ID, Course ID, Grade

Note: This study guide is designed to be programmatically appended to other


study guides.## Relationship and Entity 🔗
Relationship Types
A relationship is a set of meaningful associations between one or more
participating entity types.

Degree of a Relationship
The degree of a relationship is defined as the number of entities associated with
the relationship.

Unary or Recursive Relationship: A relationship between instances of a single


entity type.

Binary Relationship: An association between two entities.

Ternary Relationship: An association among three entities.

N-ary Relationship: The general form for degree n.

Connectivity or Cardinality
The connectivity of a relationship describes the mapping of associated entity
instances in the relationship.

One-to-One (1:1): At most one instance of an entity A is associated with one


instance of another entity B.

DBMS 2 10
One-to-Many (1:M): One instance of entity A is associated with zero, one, or
many instances of entity B.

Many-to-Many (M:M): One instance of entity A is associated with zero, one,


or many instances of entity B, and vice versa.

Attributes 📝
Attributes define the characteristics of a data object of an entity.

Types of Attributes
Type Description

Simple (or Atomic) An attribute that is composed of a single component with an


Attribute independent existence.

An attribute composed of multiple components each with an


Composite Attribute
independent existence.

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.

An attribute that represents a value that is derivable from the value


Derived Attribute
of related attributes or a set of attributes.

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.

Types of Mapping Constraints

DBMS 2 11
Type Description

One-to-One An entity in A is associated with at most one entity in B.

An entity in A is associated with any number (zero or more) of entities in


One-to-Many
B.

Many-to-One An entity in A is associated with at most one entity in B.

An entity in A is associated with any number (zero or more) of entities in


Many-to-Many
B, and vice versa.

Generalization, Specialization, and Aggregation 🔍


Generalization

Generalization is defined as the process of identifying some


common characteristics of a collection of entity sets and
creating a new entity set that contains entities possessing
these common features.

Example: Car, Bus, Bike → VEHICLE

Specialization
Specialization is defined as the process of identifying subsets
of an entity (super-class or super-type) that share some
distinguishing characteristic.

Example: VEHICLE → Salaried-Employee, Part-time-Employee, Hourly-


Employee

Aggregation

Aggregation is the process of forming higher-level entity sets


from lower-level entity sets.

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.

"It involves sharing of attributes and operations or methods


among classes based on a hierarchical structure."

Generalization
Generalization is a top-down process of defining super-classes and their related
sub-classes.

A super-class is an entity type that includes distinct sub-classes that share


common attributes.

A sub-class is an entity type that inherits all the properties of its super class
and can add its own properties.

Example: Job Branch


Job Branch Employee Manager

Job Employee Manager

Branch

Aggregation
Aggregation is the process of compiling a class from multiple objects.

"It is interesting to notice that deriving the common attributes


of more than one object creates a class."

Inheritance vs. Association/Aggregation


Inheritance is different from association or aggregation. Inheritance involves
sharing of attributes and operations among classes based on a hierarchical

DBMS 2 13
structure, whereas association and aggregation involve relationships between
objects.

📝 Superclass and Subclass


Superclass
A superclass is an entity type that includes distinct sub-classes that share
common attributes.

Subclass
A subclass is an entity type that inherits all the properties of its super class and
can add its own properties.

Superclass Subclass

Attributes Inherited attributes + Unique attributes

Example: Banking System


// Superclass: Account
class Account {
// Attributes
accountNumber;
accountHolder;
}

// 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 no Address Correspondence

Patient name

Age

Library Management System E-R Diagram


Book Author Branch

Book ID Author ID Branch ID

Title Name Address

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

Limited scope for automated query optimization

Network Model
Advantages:

Simplicity

Data sharing

Data security

Data integrity

Disadvantages:

System complexity

Operational anomalies

Not user-friendly

Absence of structural independence

Limited scope for automated query optimization

Relational Model
Advantages:

Simplicity

No anomalies

Structural independence

Easier design, implementation, maintenance, and usage

Better query capability

Disadvantages:

DBMS 2 16
Hardware overheads

Easier to design (can lead to poorly designed DBMS)## 📚 Database Design


Inefficiencies 💻
Database design inefficiencies may not be highlighted when the database is small,
but as the database grows, poorly designed databases will slow down the system,
resulting in performance degradation and data corruption.

🌊 Phenomenon of Information Islands 🌴


The ease of implementing and using relational database systems can create a
situation where many people or departments create their own databases and
applications, known as information islands. These individual databases will
prevent information integration, which is essential for the smooth and efficient
functioning of the organization.

📊 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.

They use the database without any intermediary application programs.

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.

Types of File Organization


File Organization Description

Sequential File Records are written one after another in the order they are
Organization created, and can be accessed only in that order.

Provides an effective way to access individual records directly,


Relative File
with a predictable relationship between the key and the record's
Organization
location in the file.

DBMS 2 18
Indexed Sequential File An effective way of organizing records when there is a large
Organization number of records and frequent updates.

Factors Influencing File Organization Choice


Economy of storage

Convenience of updates

Ease of retrieval

Reliability

Security

Integrity## Indexed Sequential File Organization 📂


An indexed sequential file organization provides a combination of access types
supported by a sequential file and a relative file. This structure can be thought of
as an index with pointers in a sequential file.

Benefits
Records can be accessed sequentially and directly

Supports interactive as well as batch-oriented applications

Supports updating and deletion of records

Drawbacks
Can only be stored on disks

Involves more overhead in the form of maintenance of indexes

Records cannot be of fixed length

Multi Key File Organization 📊


In some applications, support for multi-key files is required. For example, in a
banking system, different types of users (tellers, loan officers, branch managers,
etc.) need to access the same data in different ways.

DBMS 2 19
Challenges
Duplication of data is not desirable

Inconsistencies may occur

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.

Hash File Organization


In a hash file, records do not have to be written sequentially to the file. Instead, a
hash function calculates the address of the page in which the record is to be
stored based on one or more fields in the record. The base field is called the hash
field or hash key.

Hash Function Techniques


Folding: applies an arithmetic function, such as addition, to different parts of
the hash field.

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.

Collision resolution techniques:

Open addressing

Separate chaining (see example below)

Example: Separate Chaining 📋


Suppose we have a chained hash table with 9 slots and the hash function is A(k) =
k mod 9. We insert the elements 5, 28, 19, 15, 20, 33, 12, 17, 10 into the table.

Index Slot Linked List

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.

Key Hash Value Probe Number Final Index

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

The final hash table is:

Index Key

0 21

1 65

2 88

4 26

5 37

6 59

10 76

Primary Clustering: Linear probing suffers from primary clustering, where a


cluster of occupied slots is formed, increasing the number of probes required to
find a free slot.

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.

Key Hash Value Probe Number Final Index

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

The final hash table is:

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.

Key h1(k) h2(k) Probe Number Final Index

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

The final hash table is:

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:

"A B-tree of order m can be defined as an m-way search tree


which is either empty or satisfies the following properties:All
leaf nodes are at the same level.All non-leaf nodes (except root
node) should have at least ⌈m/2⌉ children.All nodes (except
root) should have at least ⌈m/2⌉ - 1 keys.If the root node is a
leaf node (only node in the tree), it will have no children and will

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.

Keys in a Node: The number of keys in a node is between ⌈order/2⌉ - 1 and


order - 1.

Example of a B-Tree of Order 5


_______
/ \
/ \
/ \
40 80
/ \ / \
/ \ / \
10 30 60 90
/ \ / \ / \ / \
1 5 20 35 45 55 70 85

Variations of B-Trees

DBMS 2 25
2-3 Tree: A B-Tree of order 3.

2-4 Tree: A B-Tree of order 4.

📈 B+ Trees 📈
A variation of B-Trees, well-suited for disk access.

Differences from B-Trees


Structure of Leaf Nodes: Leaf nodes store keys and their corresponding data
items, while internal nodes store only keys and child pointers.

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.

Properties of Relational Tables


Values are Atomic: Columns in a relational table are not repeating groups or
arrays.

Column Values are of the Same Kind: All values in a column come from the
same domain.

Each Row is Unique: No two rows in a relational table are identical.

Each Column has a Unique Name: Column names are unique.

Sequence of Rows is Insignificant: The order of rows does not matter.

Sequence of Columns is Insignificant: The order of columns does not matter.

🤔 DBMS vs RDBMS 🤔
Differences
DBMS RDBMS

Relationship between Programmatically


Specified at the time of table creation
tables specified

Client/Server
Not supported Supported
Architecture

Distributed
Not supported Supported
Databases

Tight security not Multiple levels of security (e.g., logging,


Security
guaranteed command level, object level)

Each table has its own Many tables are grouped into one
Table Extensions
extension database

May satisfy less than 7


Codd's Rules Usually satisfies more than 7 rules
rules

📝 📝
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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy