-- Feb 26 In-Class Exercise
Eyecolor:
There are 1,000,000 records and record pointer is 6 bytes => 1,000,000 * 6 = 6,000,000 bytes
There are three possible values for eyecolor and each consists of an integer (4 bytes) and a record pointer (6 bytes) => (4 + 6) * 3 = 30 bytes
Therefore, total is 6,000,000 + 30 = 60,000,030 bytes
One block is 4096 bytes => 60,000,030 bytes / 4096 bytes = 1,465 blocks
Haircolor:
Same as eyecolor, there is a total of 6,000,000 bytes for 1,000,000 records.
There are 5 possible values for haircolor and each consists of an integer (4 bytes) and a record pointer (6 bytes) => (4 + 6) * 5 = 50 bytes
Therefore, total is 6,000,000 + 50 = 60,000,050 bytes
One block is 4096 bytes => 60,000,050 bytes / 4096 bytes = 1,465 blocks
Combine both eyecolor and haircolor together, then the total of blocks needed = 1,465 + 1,465 = 2,930 blocks
Bitmap Index:
Eyecolor:
There are 1,000,000 bits for each eyecolor => 1,000,000 * 3 = 3,000,000 bits = 375,000 bytes for three possible values of eyecolor.
One block is 4096 bytes => 375,000 bytes / 4096 bytes = 92 blocks
Haircolor:
There are 1,000,000 bits for each haircolor => 1,000,000 * 5 = 5,000,000 bits = 625,000 bytes for five possible values of haircolor.
One block is 4096 bytes => 625,000 bytes / 4096 bytes = 153 blocks
Therefore, number of blocks needed for bitmap index on both eyecolor and haircolor = 92 + 153 = 245 blocks
(
Edited: 2020-02-26)
Eyecolor:
There are 1,000,000 records and record pointer is 6 bytes => 1,000,000 * 6 = 6,000,000 bytes
There are three possible values for eyecolor and each consists of an integer (4 bytes) and a record pointer (6 bytes) => (4 + 6) * 3 = 30 bytes
Therefore, total is 6,000,000 + 30 = 60,000,030 bytes
One block is 4096 bytes => 60,000,030 bytes / 4096 bytes = 1,465 blocks
Haircolor:
Same as eyecolor, there is a total of 6,000,000 bytes for 1,000,000 records.
There are 5 possible values for haircolor and each consists of an integer (4 bytes) and a record pointer (6 bytes) => (4 + 6) * 5 = 50 bytes
Therefore, total is 6,000,000 + 50 = 60,000,050 bytes
One block is 4096 bytes => 60,000,050 bytes / 4096 bytes = 1,465 blocks
Combine both eyecolor and haircolor together, then the total of blocks needed = 1,465 + 1,465 = 2,930 blocks
Bitmap Index:
Eyecolor:
There are 1,000,000 bits for each eyecolor => 1,000,000 * 3 = 3,000,000 bits = 375,000 bytes for three possible values of eyecolor.
One block is 4096 bytes => 375,000 bytes / 4096 bytes = 92 blocks
Haircolor:
There are 1,000,000 bits for each haircolor => 1,000,000 * 5 = 5,000,000 bits = 625,000 bytes for five possible values of haircolor.
One block is 4096 bytes => 625,000 bytes / 4096 bytes = 153 blocks
Therefore, number of blocks needed for bitmap index on both eyecolor and haircolor = 92 + 153 = 245 blocks