Disk Representations: Files, Pages, Records
STORING DATA: FILES
FILE REPRESENTATIONS
Overview: Representations
SSN | Last Name | First Name | Age | Salary |
123 | Adams | Elmo | 31 | $400 |
443 | Grouch | Oscar | 32 | $300 |
244 | Oz | Bert | 55 | $140 |
134 | Sanders | Ernie | 55 | $400 |
Record
Bob
M
32
400
Harmon
Varchar
Varchar
Char
Int
Int
Slotted Page
Page�Header
File
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Header
M
94703
Bob
Harmon
32
Byte Representation of Record
Overview: Files of Pages of Records
Page�Header
Page�Header
Page�Header
Page�Header
Page�Header
Page�Header
DATABASE FILES
Files of Pages of Records
Many DB File Structures
Unordered Heap Files
Heap File Implemented as List
Data
Page
Data
Page
Data
Page
Data
Page
Data
Page
Data
Page
Header
Page
Pages with
Free Space
Full Pages
Better: Use a Page Directory
Data
Page 1
Data
Page 2
Data
Page N
Header Page
DIRECTORY
Summary
SSNz | Last Name | First Name | Age | Salary |
123 | Adams | Elmo | 31 | $400 |
443 | Grouch | Oscar | 32 | $300 |
244 | Oz | Bert | 55 | $140 |
134 | Sanders | Ernie | 55 | $400 |
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
File
PAGE LAYOUT
Page Basics: The Header
Page Header
Things to Address
Page Header
Options for Page Layouts
Indexes: Sneak Preview
Content Break
A Note On Imagery
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
Fixed Length Records, Packed
Page Header
Record
Record
Record
Record
Record
Record
Fixed Length Records, Packed, Pt 2.
Page Header
Record
Record
Record
Record
Record
Record
Record id:
(Page 2, Record 4)
Fixed Length Records: Packed, Pt 3.
Record id:
(Page 2, Record 4)
Page Header
Record
Record
Record
Record
Record
Fixed Length Records: Packed, Pt. 5
Page Header
Record
Record
Record
Record
Record
Record id:
(Page 2, Record 3)
Fixed Length Records: Unpacked
Page Header
Record
Record
Record
Record
Record
Record
Record
Bitmap
Record id:
(Page 2, Record 4)
Fixed Length Records: Unpacked, Pt. 2
Record id:
(Page 2, Record 4)
Page Header
Record
Record
Record
Record
Record
Record
Record
Bitmap
Content Break 2
Variable Length Records
Record id:
(Page 2, Record 4)
Page Header
Record
Record
Record
Record
Record
Record
First: Relocate metadata to footer
Footer
Record
Record
Record
Record
Record
Slotted Page
Footer
Record
Record
Record
Record
Record
16
24
32
12
18
Record Id:
(Page 2, Record 4)
Slot Directory
Slotted Page: Delete Record
Footer
Record
Record
Record
Record
Record
16
24
32
18
Slot Directory
Record Id:
(Page 2, Record 4)
Slotted Page: Insert Record
Footer
Record
Record
Record
Record
Record
16
24
32
18
Slot Directory
Record Id:
(Page 2, Record 4)
Slotted Page: Insert Record, Pt 2.
Footer
Record
Record
Record
Record
Record
16
24
32
18
Slot Directory
Record
Record Id:
(Page 2, Record 4)
Slotted Page: Insert Record, Pt. 3
slot in slot directory
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
Record
Record Id:
(Page 2, Record 4)
Slotted Page: Insert Record, Pt. 4
slot in slot directory
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
Record
Record Id:
(Page 2, Record 4)
Slotted Page: Insert Record, Pt. 5
slot in slot directory
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
Record
Record Id:
(Page 2, Record 4)
Slotted Page: Insert Record, Pt. 6
slot in slot directory
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
Record Id:
(Page 2, Record 4)
Slotted Page: Leading Questions
don’t change.
record addition and then reorganize.
never gets more records.
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
Record Id:
(Page 2, Record 4)
Slotted Page: Growing Slots
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
5
Record Id:
(Page 2, Record 4)
Slotted Page: Growing Slots, Pt. 2
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
5
Record
16
Record Id:
(Page 2, Record 4)
Slotted Page: Growing Slots, Pt. 3
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
6
Record
16
Record Id:
(Page 2, Record 4)
Slotted Page: Summary
Footer
Record
Record
Record
Record
Record
16
24
32
42
18
Slot Directory
6
Record
16
RECORD LAYOUT
Record Formats
Record Formats
Record Formats: Fixed Length
3
T
HELLO_W
INTEGER
DOUBLE
BOOLEAN
INTEGER
CHARACTER(7)
3.142
3
4
8
1
4
7
24
Record Formats: Variable Length
Record
Bob
M
32
94703
Big, St.
VARCHAR
VARCHAR
CHAR
INT
INT
Bob
M
32
94703
Big, St.
CHAR(20)
CHAR(18)
CHAR
INT
INT
Wasted Space
Alice
M
32
94703
CHAR(20)
CHAR(18)
CHAR
INT
INT
Boulevard of the Allies
Field Not Big Enough
Record Formats: Variable Length, Pt 2.
Comma Separated Values (CSV)
Bob
VARCHAR
Big, St.
VARCHAR
M
CHAR
32
INT
94703
INT
,
,
,
,
Record
Bob
M
32
94703
Big, St.
VARCHAR
VARCHAR
CHAR
INT
INT
Record Formats: Variable Length, Pt. 3
Comma Separated Values (CSV)
Bob
VARCHAR
Big, St.
VARCHAR
M
CHAR
32
INT
94703
INT
,
,
,
,
Record
Bob
M
32
94703
Big, St.
VARCHAR
VARCHAR
CHAR
INT
INT
Record Formats: Variable Length, Pt 5.
Comma Separated Values (CSV)
Bob
VARCHAR
Big, St.
VARCHAR
M
CHAR
32
INT
94703
INT
,
,
,
,
Record
Bob
M
32
94703
Big, St.
VARCHAR
VARCHAR
CHAR
INT
INT
Record Formats: Variable Length, Pt. 7
Bob
VARCHAR
Big, St.
VARCHAR
M
CHAR
32
INT
94703
INT
Header
Record
Bob
M
32
94703
Big, St.
VARCHAR
VARCHAR
INT
INT
Summary 2
SSN | Last Name | First Name | Age | Salary |
123 | Adams | Elmo | 31 | $400 |
443 | Grouch | Oscar | 32 | $300 |
244 | Oz | Bert | 55 | $140 |
134 | Sanders | Ernie | 55 | $400 |
Record
Bob
M
32
400
Harmon
Varchar
Varchar
Char
Int
Int
Slotted Page
Page�Header
File
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Header
M
94703
Bob
Harmon
32
Byte Representation of Record
Content Break 3
System Catalogs
System Catalogs Pt. 2
PostgreSQL Information Schema
sqlite_master
Files: Summary
indexes and views.