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 We assume that records are smaller than a disk block Database System Concepts-7th Edition 13.2 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 13.2 ©Silberschatz, Korth and Sudarshan th Edition 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 ▪ We assume that records are smaller than a disk block
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 record 0 10101 Srinivasan Comp.Sci. 65000 record 1 12121 Wu Finance 90000 record 2 15151 Mozart Music 40000 record 3 22222 Einstein Physics 95000 record 4 32343 El Said History 60000 record 5 33456 Gold Physics 87000 record 6 45565 Katz Comp.Sci. 75000 record 7 58583 Califieri History 62000 record 8 76543 Singh Finance 80000 record 9 76766 Crick Biology 72000 record 10 83821 Brandt Comp.Sci. 92000 record 11 98345 Kim Elec.Eng. 80000 Database System Concepts-7th Edition 13.3 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 13.3 ©Silberschatz, Korth and Sudarshan th Edition 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 recordsi+1,...,n to i,...,n-1 move recordn to i do not move records.but link all free records on a free list Record 3 deleted record 0 10101 Srinivasan Comp.Sci. 65000 record 1 12121 Wu Finance 90000 record 2 15151 Mozart Music 40000 record 4 32343 El Said History 60000 record 5 33456 Gold Physics 87000 record 6 45565 Katz Comp.Sci. 75000 record 7 58583 Califieri History 62000 record 8 76543 Singh Finance 80000 record 9 76766 Crick Biology 72000 record 10 83821 Brandt Comp.Sci. 92000 record 11 98345 Kim Elec.Eng. 80000 Database System Concepts-7th Edition 13.4 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 13.4 ©Silberschatz, Korth and Sudarshan th Edition 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 record 0 10101 Srinivasan Comp.Sci. 65000 record 1 12121 Wu Finance 90000 record 2 15151 Mozart Music 40000 record 11 98345 Kim Elec.Eng. 80000 record 4 32343 El Said History 60000 record 5 33456 Gold Physics 87000 record 6 45565 Katz Comp.Sci. 75000 record 7 58583 Califieri History 62000 record 8 76543 Singh Finance 80000 record 9 76766 Crick Biology 72000 record 10 83821 Brandt Comp.Sci. 92000 Database System Concepts-7th Edition 13.5 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 13.5 ©Silberschatz, Korth and Sudarshan th Edition 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 recordn to i do not move records,but link all free records on a free list header record 0 10101 Srinivasan Comp.Sci. 65000 record 1 record 2 15151 Mozart Music 40000 record 3 22222 Einstein Physics 95000 record 4 record 5 33456 Gold Physics 87000 record 6 record 7 58583 Califieri History 62000 record 8 76543 Singh Finance 80000 record 9 76766 Crick Biology 72000 record 10 83821 Brandt Comp.Sci. 92000 record 11 98345 Kim Elec.Eng. 80000 Database System Concepts-7th Edition 13.6 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 13.6 ©Silberschatz, Korth and Sudarshan th Edition 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