sequential files outline
play

Sequential Files : Outline ! Overview ! Ordered vs. Unordered ! - PowerPoint PPT Presentation

Sequential Files : Outline ! Overview ! Ordered vs. Unordered ! Physical sequential Files ! Physical Linked Sequential Files ! COBOL rasitjutrakul Sequential Files " Logically the records are stored consecutively Physical sequential file


  1. Sequential Files : Outline ! Overview ! Ordered vs. Unordered ! Physical sequential Files ! Physical Linked Sequential Files ! COBOL rasitjutrakul

  2. Sequential Files " Logically the records are stored consecutively – Physical sequential file block 1 block 2 block 3 block n ... – Physical linked sequential file ... block 1 block 3 block n block 1 block 3 block n block 2 block 2 Batch and RetrieveAll Batch and RetrieveAll rasitjutrakul

  3. Ordered and Unordered " Ordered sequential files – the logical records are stored sequentially in increasing (or decreasing) order according to their primary key values. " Unordered sequential files – the logical records are stored no in any specific order. rasitjutrakul

  4. Notations " Let S be a file – NR : the number of logical records – BF : the blocking factor – NBLK : the number of blocks " SL [ operation, S ] : search length " sba : sequential block access " rba : random block access rasitjutrakul

  5. Physical Sequential Files " Tape files – Unordered files – Ordered files " Disk files – Unordered files – Ordered files rasitjutrakul

  6. Tape Files : Unordered = SL RetrieveAll S [ , ] NBLK sba + NBLK 1 = SL [ RetrieveOne S , ] sba ( found ) avg 2 = SL RetrieveOne S [ , ] NBLK sba ( not found ) Never would one use unordered sequential file if one permits InsertOne, DeleteOne, and UpdateOne operations. rasitjutrakul

  7. Tape Files : Ordered " Require intial sorting operation of the given file. " Batch mode update processing : – InsertOne, DeleteOne, and UpdateOne " Batch mode retrieve processing : – Batch and RetrieveFew = SL RetrieveAll [ , S ] NBLK sba + NBLK 1 = SL [ RetrieveOne , S ] sba ( found ) avg 2 = SL RetrieveOne [ , S ] NBLK sba ( not found ) rasitjutrakul

  8. Transaction Files " A sequential file contains all logical records that are to be either updated, deleted, and/or inserted into the master file. – updated U Record – deleted D Record – inserted I Record operational field operational field rasitjutrakul

  9. Batch Mode MF NMF Batch Update Batch Update TF Sort NTF Sort TF : Transaction file NTF : New transaction file (ordered) MF : Master file (ordered) NMF : New mater file (ordered) rasitjutrakul

  10. Batch Mode D 125321Somboon TF NMF I 233218Somkuan 012834Somchai I 235089Somhatai 232117Somkid U 255989Somsak 233218Somkuan I 817222Somwai 235089Somhatai Batch Update Batch Update 012834Somchai 255989Somsak 125321Somboon 592211Somsri 232117Somkid 817222Somwai 255989Somsuk 877652Somwang 592211Somsri MF 877652Somwang rasitjutrakul

  11. Disk Files : Unordered " Search length : same as the unordered tape files. – RetrieveAll – RetrieveOne (found) – RetrieveOne (not found) " UpdateOne can be done in place. L O + 1 NBLK , ] = + M P SL avg [ UpdateOne S 1 N Q sba 2 rasitjutrakul

  12. Unordered Disk Files : Delete " DeleteOne : flagging the record – same search length as UpdateOne ... rec. # 1 rec. # 2 rec. # 3 rec. # n L O + 1 NBLK , ] = + M P SL avg [ UpdateOne S 1 N Q sba 2 rasitjutrakul

  13. Unordered Disk Files : Insert " InsertOne – append : retrieve the last block " if there is space, rewrite the updated block 1 rba + 1 sba " if full, get next block and rewrite the block 1 rba + 2 sba – allocate empty slot in each block " operation cost is the same as DeleteOne rec. # 5 rec.# 6 rec. # 7 empty slot rasitjutrakul

  14. Disk Files : Ordered " RetrieveAll : NBLK sba " RetrieveOne : – sequential search – binary search – step search " UpdateOne, DeleteOne, InsertOne* : – 1 sba + the avg SL of RetrieveOne rasitjutrakul

  15. Ordered Disk Files : RetrieveOne Sequential search L O + 1 NBLK ] = + M P SL [ UpdateOne , S 1 N Q sba avg 2 Binary search L M O , ] = + + 1 1 NBLK sba P SL UpdateOne [ S N Q avg 2 Step search L O + 1 NBLK ] = + M P SL avg [ UpdateOne , S 1 N Q sba 2 rasitjutrakul

  16. Reorganization " Deleting records by flagging – does not physically delete the records. " Reorganization from time to time – Copying all unflagged records to a new file. – Purging the old file. rasitjutrakul

  17. Physical Linked Sequential Files " Physical sequential files – InsertOne & DeleteOne cause file to be cluttered " Physical linked sequential files – Block pointers preserve block adjacency. – Blocks could be dispersed on the disk. – Each block access is a random access. – Ok for highly active files. ... block 1 block 3 block n block 1 block 3 block n block 2 block 2 rasitjutrakul

  18. Physical Linked Sequential Files " Binary search can not be done. Unordered Ordered RetrieveAll NBLK rba NBLK rba RetrieveOne (found) (1+ NBLK ) / 2 rba (1+ NBLK ) / 2 rba RetrieveOne (not found) NBLK rba (1+ NBLK ) / 2 rba ... block 1 block 3 block n block 1 block 3 block n block 2 block 2 rasitjutrakul

  19. Unordered Files : InsertOne 6 1 rba + 1sba 6 2 1 rba + 1sba 4 6 2 2 rba + 1sba 4 1 6 2 1 rba + 1sba rasitjutrakul

  20. Unordered Files : DeleteOne 4 1 5 8 6 2 RetrieveOne + 1 sba 4 1 5 8 2 RetrieveOne + 1 sba 4 1 5 2 RetrieveOne + 1 sba 4 1 2 rasitjutrakul

  21. Ordered Files : InsertOne 1 6 15 RetrieveOne + 1 sba 6 12 15 1 RetrieveOne + 1 rba + 1sba 6 9 1 12 15 RetrieveOne + 1 rba + 2 sba 1 6 7 9 12 15 RetrieveOne + 2 rba + 2 sba 1 6 7 9 12 15 10 RetrieveOne + 2 rba + 3 sba 1 6 8 9 12 15 7 10 rasitjutrakul

  22. Sequential Files in COBOL FILE SECTION. FD OLD-MASTER LABEL RECORDS ARE STANDARD BLOCK CONTAINS 20 RECORDS 01 OLD-MASTER-REC. 05 M-ACCT-NO PIC X(5). 05 AMOUNT-DUE PIC 9(4)V99. 05 FILLER PIC X(89). ... OPEN INPUT OLD-MASTER TRANS-FILE OUTPUT NEW-MASTER. READ OLD-MAS-REC AT END MOVE HIGH-VALUES TO M-ACCT-NO. ... CLOSE OLD-MASTER TRANSF-FILE NEW-MASTER. rasitjutrakul

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend