Presentation is loading. Please wait.

Presentation is loading. Please wait.

12.5 Record Modifications Jayalakshmi Jagadeesan Id 106.

Similar presentations


Presentation on theme: "12.5 Record Modifications Jayalakshmi Jagadeesan Id 106."— Presentation transcript:

1 12.5 Record Modifications Jayalakshmi Jagadeesan Id 106

2 Various Record Modifications Insertion Deletion Update

3 Record Modification Modifications to records: – insert – delete – update issues even with fixed-length records and fields even more involved with variable-length data

4 Insertion If records of relation are in no particular order find a block with empty space,put there

5 Insertion If there is any particular order -locate appropriate block -slides records around the block

6 Insertion If there is no room for the record in the block, -find space in a nearby block -create an overflow block

7 Inserting New Records If records need not be any particular order, then just find a block with enough empty space Later we'll see how to keep track of all the tuples of a given relation But what if blocks should be kept in a certain order, such as sorted on primary key?

8 Insertion in Order If there is space in the block, then add the record (going right to left), add a pointer to it (going left to right) and rearrange the pointers as needed.

9 What if Block is Full? Records are stored in several blocks, in sorted order One approach: keep a linked list of "overflow" blocks for each block in the main sequence Another approach is described in the book

10 Deletion If we cannot slide records, -maintain an available-space list in the block header -we may be able to do with an overflow block

11 Deletion However we have one complication in Deletion -pointers to the deleted record? Idea place a tombstone in place of record

12 Deletion A bit at the record header serves as tombstone 0 - if record is not deleted 1 - if record is deleted

13 Deleting Records Try to reclaim space made available after a record is deleted If using an offset table, then rearrange the records to fill in any hole that is left behind and adjust the pointers Additional mechanisms are based on keeping a linked list of available space and compacting when possible

14 Tombstones What about pointers to deleted records? We place a tombstone in place of each deleted record Tombstone is permanent Issue of where to place the tombstone Keep a tombstone bit in each record header: if this is a tombstone, then no need to store additional data

15 Update Fixed length record no effect on the storage system Variable length record problems associated with Insertion and Deletion

16 Update If updated record is longer, create more space on its block

17 Updating Records For fixed-length records, there is no effect on the storage system For variable-length records: – if length increases, like insertion – if length decreases, like deletion except tombstones are not necessary

18 Thank You!!!


Download ppt "12.5 Record Modifications Jayalakshmi Jagadeesan Id 106."

Similar presentations


Ads by Google