Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Storage & File organization

1
• The tables are stored as database files inside
secondary storage
• The data transfer between disk and memory
takes place in units of block.
• Block size is 2KB, 4KB, 8KB, 16KB, 32KB

2
• File organization determines various access
methods for
– storing and
– retrieving records from database file.

3
Different file organization

• Heap files (unsorted file)


• Sorted file (Sequential file)
• Hash file

4
Heap files

• Insertion is highly efficient


• Update and search are time
consuming.
• Deletion also is time consuming and deletion
of record creates a hole in the page.
• Only linear search can be performed.
5
Sorted file

• The records of the file remains sorted with


respect to an attribute or a group of attribute.

• The sorting attribute is called sort key.


• The sort key may be simple or composite.

6
Sorted file

• Searching a sorted file with respect to sort key


is efficient because one can perform binary
search.
• Deletion, update and insertion are expensive.

7
8
Hash file

• A hash function is used to distribute the


records of a file among buckets.
• The simplest hash function is division
remainder function.
• Insertion, deletion, update and search are
highly efficient.
9
Hash file
Employee(name, age, salary)

10
Static hashing

11
Primary index

Index based on
an ordering key
column is called
primary index.

12
Secondary index

Index based on
any non-ordering
column is called
secondary index.

13
Dense index

If there exists index record for every distinct value


of the indexing column then the index is called dense index.
14
Sparse index

If there does not exists index record for every distinct value
of the indexing field then the index is called sparse index.
15
16

You might also like