Lecture 17
Lecture 17
Database Systems
Zubaira Naz
Information Technology University (ITU)
File Organization
• The database is stored as a collection of files.
• Each file is a sequence of records.
• A record is a sequence of fields.
• One approach:
–assume record size is fixed
–each file has records of one particular type only
–different files are used for different relations
This case is easiest to implement; will consider
variable length records later.
Fixed-Length Records
• Simple approach:
– Store record i starting from byte n * (i – 1), where n is the size
of each record.
– Record access is simple but records may cross blocks
• Modification: do not allow records to cross block boundaries
Fixed-Length Records
• Deletion of record i: alternatives:
– move records i + 1, . . ., n to i, . . . , n – 1
– move record n to i
– do not move records, but link all free records on a free list
Record 3 deleted
Fixed-Length Records
• Deletion of record i: alternatives:
– move records i + 1, . . ., n to i, . . . , n – 1
– move record n to i
– do not move records, but link all free records on a free list
Record 3 deleted and replaced by record 11
Fixed-Length Records
• Deletion of record i: alternatives:
– move records i + 1, . . ., n to i, . . . , n – 1
– move record n to i
– do not move records, but link all free records on a free list
Variable-Length Records
• Variable-length records arise in database systems in several ways:
– Storage of multiple record types in a file.
– Record types that allow variable lengths for one or more fields such as
strings (varchar)
– Record types that allow repeating fields (used in some older data
models).
• Attributes are stored in order
• Variable length attributes represented by fixed size (offset, length),
with actual data stored after all fixed length attributes
• Null values represented by null-value bitmap
Variable-Length Records: Slotted Page Structure
Block Header Records
department
instructor
multitable clustering
of department and
instructor
Multitable Clustering File Organization (cont.)