Course Code: Comp 324 Course Name: Database Management System II Lecture 5: File Organization

You might also like

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

Course Code: Comp 324

Course Name: Database Management System II

Lecture 5: File Organization

Lecturer Name: Laura Limo


Devotional Meditation

Ephesians 6:1-3
6 Children, obey your parents in the Lord, for this is
right. 2 “Honor your father and mother”—which is the first
commandment with a promise— 3 “so that it may go well
with you and that you may enjoy long life on the earth.”
Lecture Outline
1. Recap on files and file organization
2. File organization
3. Types of file organization
4. Class Activity (Moodle)
Recap
• Databases are stored physically as files of records, which are
typically stored on magnetic disks.
• A page is a unit of exchange between the disk and the main
memory.
• A file is a sequence of records stored in a binary format on
external media storage.
• Two main operations executed on the files: retrieval operations
and update operations.
• Data is read into memory for information processing and written
to disk for persistent storage.
Organizing files and records on disk
Records vs Record types
• Record Type:

• A record would thus be: STUDENT (202020, “John Doe”, “Nakuru”, “dbms”,2)
Fixed-length vs variable-length records in files
• Fixed-length records are records in the file which are of the same size in bytes. Therefore, they
can easily be allocated to blocks while variable-length records are records in the file which are of
different sizes.
Reasons for the different sizes:
• Record maybe of same type, but one or more fields maybe of varying lengths e.g names of
different sizes
• Record maybe of same type, but one or more fields may be a repeating field with multiple values.
• One or more fields may be optional
• A file may contain records of different record type.
The records of a file must be allocated to disk blocks because a block is the unit of data transfer disk
and main memory.
File Organization
• File organization is a method of arranging the records in a file
when the file is stored on disk.
• Each file organization makes certain operations efficient but other
operations expensive.
• It defines how records in a file are mapped onto the disk.
• The goal of file organization is to provide the database system
with good performance.
• There are a number of commonly used file organization which
can determine how the records of a file are physically placed on
disk.
Types of file organization

• Heap file organization: It places records on disk in no particular


order. Records are stored in the file in the order in which they are
inserted, and new records are always placed at the end of the file.
• Sorted sequential file organization: It holds records in a
particular order based on the value of a specified field/attribute.
Records in a file can be physically ordered based on the values of
one of their fields (ordering field).
• Hash file organization: It uses a hash function to decide where a
record should be placed on the disk. It is based on the use of
hashing techniques, which can provide very efficient access to
records based on certain search conditions.

You might also like