Binary File Storage: Student Relation Example, Study notes of Computer Science

An example of how to store data in a binary file using a student relation. The concept of tuples, block size, block header, and free space. It is an essential read for students and researchers in the field of database management and computer science.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-z1k
koofers-user-z1k 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
An example for the data file.
The data file must be stored in binary format. The following example should clarify the things.
Suppose the Relation – Student has 3 records.
Id(4 bytes) Name(5 Bytes)
1 Jones
2 John
3 Tom
4 Jim
The Id column is of size 4 bytes. The name column is of size 5 bytes ( Add an extra byte to
represent the end of char '\0' ) That makes it a total of 10 bytes per tuple.
Assume these tuples are stored randomly across data blocks within the same data file. The values
used (size of block and tuple) are for the purpose of example only. The actual values may be
different as per your implementation. The
Block Size: 32 bytes.
Block header: 2 bytes ( This stores the number of tuples in the block).
Tuple size : 10 bytes.
Note that in this example, the tuples were stored randomly across the blocks.
The block as a whole has to be read/written from/to the binary file as and when required.
111
Tuple
1
Tuple
3
Tuple
2
Block 3 begins
Block 2 begins
Block 1 begins
Block Header Tuple stored in this block
Tuple
4
32 bytes long block
Free space
Free space
Free space

Partial preview of the text

Download Binary File Storage: Student Relation Example and more Study notes Computer Science in PDF only on Docsity!

An example for the data file.

The data file must be stored in binary format. The following example should clarify the things.

Suppose the Relation – Student has 3 records.

Id(4 bytes) Name(5 Bytes)

1 Jones

2 John

3 Tom

4 Jim

The Id column is of size 4 bytes. The name column is of size 5 bytes ( Add an extra byte to

represent the end of char '\0' ) That makes it a total of 10 bytes per tuple.

Assume these tuples are stored randomly across data blocks within the same data file. The values

used (size of block and tuple) are for the purpose of example only. The actual values may be

different as per your implementation. The

Block Size: 32 bytes.

Block header: 2 bytes ( This stores the number of tuples in the block).

Tuple size : 10 bytes.

Note that in this example, the tuples were stored randomly across the blocks.

The block as a whole has to be read/written from/to the binary file as and when required.

Tuple

Tuple

Tuple

Block 3 begins

Block 2 begins

Block 1 begins

Block Header

Tuple stored in this block

Tuple

32 bytes long block

Free space Free space Free space