Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sequential Files Chapter 13. Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies.

Similar presentations


Presentation on theme: "Sequential Files Chapter 13. Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies."— Presentation transcript:

1 Sequential Files Chapter 13

2 Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies data in areas like payroll, inventory Usually processed by batch processing Usually processed by batch processing Typically stored on magnetic disk Typically stored on magnetic disk Disks can store billions of characters Disks can store billions of characters Disk drives read, write data quickly Disk drives read, write data quickly Disk records can be any size Disk records can be any size

3 Sequential Files Records always read in sequence Records always read in sequence Read first record, process it, then read second record, process it and so on Read first record, process it, then read second record, process it and so on Payroll records in order by employee number may be processed in sequence for updating or printing reports Payroll records in order by employee number may be processed in sequence for updating or printing reports

4 Sequential Files May be sorted into any sequence using any field in record May be sorted into any sequence using any field in record To distribute checks more easily, records may be sorted by department To distribute checks more easily, records may be sorted by department Sequential processing then used to print checks, reading first record, then second, etc. Sequential processing then used to print checks, reading first record, then second, etc.

5 Master File Procedures Typical procedures for sequential processing in batch mode are: Designing Master File Designing Master File Creating Master File Creating Master File Creating Transaction File Creating Transaction File Updating Master File Updating Master File Reporting from Master File Reporting from Master File

6 Designing a Master File Place key fields that uniquely identify record at beginning of record Place key fields that uniquely identify record at beginning of record If possible, choose numeric key fields If possible, choose numeric key fields Secondary fields after primary key fields Secondary fields after primary key fields Remaining fields appear in order of importance Remaining fields appear in order of importance

7 Designing a Master File Choose field size large enough to accommodate data stored in it Choose field size large enough to accommodate data stored in it Use coded fields where possible to save space Use coded fields where possible to save space Be sure all date fields include four-digit year Be sure all date fields include four-digit year

8 Creating a Master File Original master file data entered interactively, stored on disk file Original master file data entered interactively, stored on disk file Ensure data integrity by using data validation techniques to minimize risk or errors Ensure data integrity by using data validation techniques to minimize risk or errors Control listing or audit trail produced to show data stored in new master file and control totals Control listing or audit trail produced to show data stored in new master file and control totals

9 Creating a Transaction File Changes to master file made with separate procedure Changes to master file made with separate procedure Change records stored in file called transaction file Change records stored in file called transaction file

10 Updating a Master File Updating is process of making master file current Updating is process of making master file current Update master file by incorporating changes from transaction records Update master file by incorporating changes from transaction records

11 Reporting from a Master File Scheduled reports prepared on regular basis from data stored in master file Scheduled reports prepared on regular basis from data stored in master file Sales reports, customer bills, checks, etc. Sales reports, customer bills, checks, etc. Use detail, exception and group printing techniques Use detail, exception and group printing techniques On demand reports produced as need arises On demand reports produced as need arises May be in report form or displayed on screen May be in report form or displayed on screen

12 Sequential File Updating Two input files Input Master File (Old-Master) Input Master File (Old-Master) Current through previous updating period Current through previous updating period Does not contain changes since previous update Does not contain changes since previous update Input Transaction File (Trans-File) Input Transaction File (Trans-File) Contains changes since previous update to be applied to Old-Master Contains changes since previous update to be applied to Old-Master

13 Sequential File Updating Two output files Output Master File (New-Master) Output Master File (New-Master) Integrates data from Old-Master with all of changes from Trans-File Integrates data from Old-Master with all of changes from Trans-File Will become Old-Master for next update Will become Old-Master for next update Control Listing or Audit Trail Control Listing or Audit Trail Print file showing changes made to master file, errors during processing and control totals Print file showing changes made to master file, errors during processing and control totals

14 Sequential Master File Update Transaction File Updated Master File Master File Update Activity Report Sequential File Update

15 Ordering of Records Records in Old-Master and Trans-File must be in order by same key field Records in Old-Master and Trans-File must be in order by same key field Compare key fields to determine if given master record is to be updated Compare key fields to determine if given master record is to be updated

16 Master File 1223 ……….. 1277 ……….. 1456 ……….. 2835 ……….. 2910 ……….. 3006 ……….. 3100 ……….. 3143 ……….. 4372 ……….. ^z Transaction File 1235 ……………………..A 1273 ……………………..C 1456 ……………………..C 1543 ……………………..D 1678 ……………………..B 2910 ……………………..C 3006 ……………………..D 3098 ……………………..C 3099 ……………………..D ^z 1223 ………………………… 1235 ………………………… 1277 ………………………… 1456 ………………………… 2835 ………………………… 2910 ………………………… 3100 ………………………… 3143 ………………………… 4372 ………………………… ^z New Master File

17 Sequential Update Procedure Initially, record read from both Old-Master and Trans-File Initially, record read from both Old-Master and Trans-File Comparison of M-Acct-No and T-Acct-No determines next step Comparison of M-Acct-No and T-Acct-No determines next step

18 1) T-Acct-No = M-Acct-No Means transaction record exists with same account number as master record Means transaction record exists with same account number as master record Perform regular update, adding Trans-File amount to Old-Master amount, storing result in New-Master field Perform regular update, adding Trans-File amount to Old-Master amount, storing result in New-Master field Read next record from Trans-File Read next record from Trans-File

19 2) T-Acct-No > M-Acct-No Means master record exists for which there is no corresponding transaction record Means master record exists for which there is no corresponding transaction record Write record from Old-Master to New-Master as is, since no changes need to be made to it Write record from Old-Master to New-Master as is, since no changes need to be made to it Read next record from Old-Master Read next record from Old-Master

20 3) T-Acct-No < M-Acct-No Means transaction record exists for which there is no corresponding master record Means transaction record exists for which there is no corresponding master record Two ways to process this transaction Two ways to process this transaction Create record in New-Master file for this transaction Create record in New-Master file for this transaction May assume that T-Acct-No is invalid since no match found in Old-Master file and treat as error condition May assume that T-Acct-No is invalid since no match found in Old-Master file and treat as error condition

21 Use of HIGH-VALUES Refers to largest value in computer's collating sequence Refers to largest value in computer's collating sequence Used so all records from both Old-Master and Trans-File are processed Used so all records from both Old-Master and Trans-File are processed May reach end of Old-Master file before reaching end of Trans-File or vice versa May reach end of Old-Master file before reaching end of Trans-File or vice versa

22 Use of HIGH-VALUES When last record read from Old-Master, M- Acct-No set to HIGH-VALUES When last record read from Old-Master, M- Acct-No set to HIGH-VALUES For all remaining transaction records T-Acct-No < M-Acct-No For all remaining transaction records T-Acct-No < M-Acct-No Processed as new accounts and added to New- Master Processed as new accounts and added to New- Master

23 Use of HIGH-VALUES When last record read from Trans-File, T- Acct-No set to HIGH-VALUES When last record read from Trans-File, T- Acct-No set to HIGH-VALUES For all remaining Old-Master records T-Acct-No > M-Acct-No For all remaining Old-Master records T-Acct-No > M-Acct-No Old-Master records added to New-Master without changes Old-Master records added to New-Master without changes

24 Use of HIGH-VALUES Loop to process records ends only when both account numbers equal HIGH-VALUES Loop to process records ends only when both account numbers equal HIGH-VALUES May be used only with fields defined as alphanumeric May be used only with fields defined as alphanumeric Define account number fields with PIC of Xs even though fields contain numbers Define account number fields with PIC of Xs even though fields contain numbers

25 Validity Checking in Updating Code field may be added to each transaction record to indicate whether transaction is Code field may be added to each transaction record to indicate whether transaction is New account to be added New account to be added Update to existing account Update to existing account Deletion of existing account Deletion of existing account Comparison of keys and transaction code type enable program to detect other update errors Comparison of keys and transaction code type enable program to detect other update errors

26 Updating Master Disk in Place May read a master disk record, make changes directly to same record, and rewrite it or update it in place May read a master disk record, make changes directly to same record, and rewrite it or update it in place Only two files needed Only two files needed Master-FileOPEN as I-O Master-FileOPEN as I-O Trans-FileOPEN as INPUT Trans-FileOPEN as INPUT Use REWRITE statement to replace master disk record, currently in storage, that was accessed by preceding READ Use REWRITE statement to replace master disk record, currently in storage, that was accessed by preceding READ

27 Updating Master Disk in Place To delete a record, establish each record with an activity code field To delete a record, establish each record with an activity code field For example, Code-X = 1 if record is active, or 2 if record is inactive For example, Code-X = 1 if record is active, or 2 if record is inactive All master records initially active (1 in Code- X) All master records initially active (1 in Code- X) Master record deactivated by changing activity code to 2 Master record deactivated by changing activity code to 2

28 Updating Master Disk in Place New records cannot be added in sequence when file open for I-O New records cannot be added in sequence when file open for I-O Can add records at end of file by opening file in EXTEND mode Can add records at end of file by opening file in EXTEND mode OPEN EXTEND file-name Disk automatically positioned at end of file, immediately after last record Disk automatically positioned at end of file, immediately after last record Sort file after records added to arrange them in sequence Sort file after records added to arrange them in sequence


Download ppt "Sequential Files Chapter 13. Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies."

Similar presentations


Ads by Google