Dbms. 5 Unit Part-B

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

B+ Trees

B+ Tree are used to store the large amount of data which can not
be stored in the main memory.
Due to the fact that, size of main memory is always limited, the
internal nodes (keys to access records) of the B+ tree are stored
in the main memory.
whereas, leaf nodes are stored in the secondary memory.
**** 033*********

Advantages of B+ Tree
1. Records can be fetched in equal number of disk accesses.
2. Height of the tree remains balanced and less as compare to B
tree.
3. We can access the data stored in a B+ tree sequentially as well as
directly.
4. Keys are used for indexing.
5. Faster search queries as the data is stored only on the leaf nodes.

Insertion in B+ Tree
Step 1: Insert the new node as a leaf node

Step 2: If the leaf doesn't have required space, split the node and
copy the middle node to the next index node.
node
Step 3: If the index node doesn't have required space, split the
and copy the middle element to the next index page.
B+ Trees

Example
Insert the value 195 into the B+ tree of order 5
shown in the follbwing
figure.

78 120
* *************a*********

********T*
63 57 T*******T:**********| ******j*******r********, r*****
******
B8 110 119 200

195 will be inserted in the right sub-tree of 120 after 190.


the desired position.
Insert it at

208 A20

***
53 69
B8 - 110 119 129 100 195 200

The node contains greater than the maximum number of


elemeits i.e.
4, therefore split it and place the median node up to the parent.

*************11%*
60 18 120 90
-- ov*****
**.

**~-~
53 57
88 110 119 129 195 200

Now, the index node contains 6 children and 5 keys which violats t
B+ tree properties, therefore we need to
split it, shown as follows
B+ Trees

60
* w
***~
53 B9
***eme*r*****r*onpod 20

Deletion in B+ Tree
Step 1: Delete the key and data from the leaves.

Step 2: if the leaf node contains less than minimum number of


elements, merge down the node with its sibling and delete the key in
between them.

Step 3: if the index node contains less than minimum number of


elements, merge the node with the sibling and move down the key in
between them.

Example
Delete the key 200 from the B+ Tree shown in the
following figure.

****

. *******

190
. www.o

4 53 57 69
"revwrnri9oittrmmtmvtrumriwnnubn
101s 195 200

200 is present in the right sub-tree of 190, after 195. delete it.
K

B+ Trees

~~************
2
***.

57 89 88 110 119 129 195

Merge the two nodes by using 195, 190, 154 and 129.

******** ****

60
wwww.*****.

r*****
43
H 69 H 110 -

Now, element 120 is the singile element present in the node which is
violating the B+ Tree properties. Therefore, we need to merge it by
using 60, 78, 108 and 120.

Now, the height of B+ tree will be decreased by 1.

L 60 78 108 120

***
3 110 119 54 190
B+ Trees

File Organization
The File is a collection of records. Using the primary key, we can access
the records. The type and frequency of access can be determined by the
type of file organization which was used for a given set of records.
File organization is a logical relationship among various records. Thiss
method defines how file records are mapped onto disk blocks.
o File organization is used to describe the way in which the records are
stored in terms of blocks, and the blocks are placed on the storage
medium.
Files of fixed length records are easier to implement than the files of
variable length records.

Types of file organization:


File organization contains various methods. These particular methods have
pros and cons on the basis of access or selection. In the file organization, the
programmer decides the best-suited file organization method according to his
requirement.

Types of file organization are as follows:

************************************************
Fiie E}r#Arakz2AKLON

.**
****** **.***
e****** ******
*

*********. M . . . s****N
.
**************** *., ****W***"*****
ISAM ****.**** *********
****************************
******************"
***************************
*********
F
*** *****************

Cluster index: A Clustered index is one of the


reorders the way records in the table are special types of index which
physically stored on the disk. It sortss
and stores the data rows in the table or view
based on their values. It iss
essentially a sorted copy of the data in the indexed columns. key
Sometimes we are asked to create an index on a
in the below table. There could be non-unique key like dept-id
several employees in each department.
B+ Trees
Here, all
employees belonging to the same
within a single cluster, and the index dept-id are considered to be
pointers point to the cluster as a
whole.
Difference Between Primary Index and
Secondary Index
Definition
A primary index is an index on a set of fields that
is guaranteed not to contain duplicates. In includes the unique
contrast, primary tey -nd
is not a
primary index and may have a
secondary index is an index that
duplicates.
Order
The primary index
while the requires the rows in data blocks to be ordered on
secondary index does not have an impact on how the index key
organized in data blocks. the rows are
actuall

Number of indexes
Moreover, there is only one primary index, while
indexes. there can be
multiple seconday

Duplicates
There are no
duplicates in the primary index while there can be
secondary index. duplicates in th

Conclusion
In brief, there various types of
are
secondary index. The main difference indexes, and two of them are primay and
the between primary and
primary index is an index on a set of
field and does not secondary index is that
fields that includes the
contain primary for the
a
primary index and which duplicates,
can contain
while the
secondary index is an indexkey
duplicates. tha ist
B+ Trees
PRI1AR IN)E K
R SUS

PRIMARY INDEX
CONDARY INDE
Index en a sel of Helds tha lndes hat is not a primary
heledes the ttnique piimar
key and s guoiteed not ndendmay have
to ontnin dupicntes piicatee

Pegulre the rows n dats Does nor have an impecr


hiock te he ordered on the th ros retna
ndes key ganired an data block
There ts ondy one primary Theecan be mualiple
hdex ecdan ndexes
Thure a no
duplicates jn
the primary key Therecan be duplicates in
condar index

Indexing refers to a data structure technique that is used for quickly


retrieving entries from database files using some attributes that
have been indexed. In database
systems, indexing is comparable to
indexing in books. The indexing attributes are used to define the
indexing.
Hashing is a DBMS
technique for searching for needed data on the
disc without utilising an index structure. The hashing method is
basically used to index items and retrieve them in a DB since
for a specific item using a shorter hashed searching
key rather than the original
value is faster
Indexing:
B-tree index is the widely used data
in DBMS. It is a multilevel
structures for tree based indexing
format of tree based indexing in DBMS
technique which has balanced binary search trees. All leaf
B tree signify actual data nodes of the
pointers
(8
B+ Treees

File Organization
o The File is a collection of records. Using the primary key, we can access
the records. The type and frequency of access can be determined by the
type of file organization which was used for a given set of records.
File organization is a logical relationship among various records. This
method defines how file records are mapped onto disk blocks.
File organization is used to describe the way in which the records are
stored in terms of blocks, and the blocks are placed on the storage
medium.

Types of file organization:


File organization contains various methods. These particular methods have
pros and cons on the basis of access or selection. In the file organization, the
programmer decides the best-suited file organization method according to his
requirement.

Types of file organization are as follows:


oas9o*ssoovposg ss*ss9ersvoosn*ssessoon,

File Organization

"

****

Sequentid Heap FO Hash FO ISAM B+ ee C ster

FO FO FO
uuuuuum

Index tuning is part of database tuning for selecting and creating


indexes. The index tuning goal is to reduce the query processing time.
Potential use of indexes in dynamic environments with several ad-hoc
queries in advance is a difficult task. Index tuning involves the queries
based on indexes and the indexes are created automatically on-the-fly
No explicit actions are needed by the database users for index tuning

You might also like