1 / 22

FILE CONCEPTS

FILE CONCEPTS. The data used by the program cannot reside in main memory as it is volatile hence kept as files in the external memory.

Download Presentation

FILE CONCEPTS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FILE CONCEPTS • The data used by the program cannot reside in main memory as it is volatile hence kept as files in the external memory. • A computer file is a block of arbitrary information, or resource for storing information, which is available to a computer program and is made up of Individual sets of data called records which in turn are made up of indivisible units of data called fields • Ex: Student file -the data corresponding to a single student is a record and the roll no., name, dob, mark are the fields. • Primary key: Field that uniquely identifies a record in file. • Secondary Key: The keys other than the primary key which has a unique value for each record are called secondary keys.

  2. FILE CONCEPTS • The data, information and programs are stored in external medium as FILES –program files and data files. • BUFFER-Temporary memory while transfering files from external to internal storage. THREE ALGORITHMIC INSTRUCTIONS TO MANIPULATE A FILE LFN=Logical File Number, a reference number to be used in the solution. • Open LFN: It tells the computer that the data in the file called filename is to be used, starting at the first record. • Read LFN Record copies the next record into the internal memory or into a small holding memory called buffer memory. • Close LFN It tells the computer that the file will not be used anymore.

  3. Flowchart Symbols Start or stop Process Input or output Decision Flow line Connector Off-page connector

  4. Flowchart Symbols Process Module counter Automatic-counter loop A B S

  5. SystemFlowcharts • A system flowchart indicates the flow of data throughout the entire system. • It includes where the data are coming from keyboard, disk drive, etc., the name of the program to be processed, and where the information is to go disk drive, tape drive, printer,etc. MONITOR KEYBOARD DISK DRIVE PROGRAM PRINTER

  6. EXAMPLE OF A SYSTEMFLOWCHART MASTER FILE PROCESSPROGRAM NEW FILE REPORT

  7. DESIGNING RECORDS RECORD DATA DICTIONARY FILENAME:MAILING LIST

  8. RECORD LAYOUT

  9. Designing Records While designing a records , there are many items to consider such as the number of items and their order, data types, and lengths, and the total record length 1.The number of fields is the number of items you listed under the Item Description. 2.The order of the fields is determined by the order of importance of the data. 3.The name of the fields should correspond to the item descriptions of the data. 4.The data type of each field is determined by the requirements of the solution 5.The length of the field is largely determined by the number of characters in the field. 6.Records are normally stored in external memory in blocks or section of a specific length.

  10. Sequential Access File Applications Processing Sequential-Access Files • EOF • Primer Read • Designing Output records • Headings and Line Counters

  11. Algorithm And Flowchart Of Control Module For Sales Problem Control Control Module 1.Process Init 2.While NOT EoF(1) 1.Process Calc 2.Process Print 3.Process Read While End 3.Process Wrap-up 4.End Init While Not EOF(1) F T Calc Print Read Wrap up End

  12. ALGORITHM FOR INIT MODULE Init 1.Open 1, Sales file 2.Sales Total = 0 3.MaxLineCt = 60 4.PageNo = 1 5.Process Read 6.Process Report Headings 7.Exit.

  13. FLOWCHART FOR INIT MODULE Init Open 1 Sales File Sales Total=0 Max Line Ct = 60 PageNo=1 Read Report Headings Exit

  14. ALGORITHM AND FLOWCHART FOR READ MODULE Read 1.Read Record 2.Exit Read Read Record Exit

  15. Report Readings 1.Write Report Readings 2.Get Date from System 3.Write Date 4.Line Ct=6 5.Process Column Headings 6.Exit ALGORITHM FOR REPORT HEADINGS MODULE

  16. FLOWCHART FOR REPORT HEADINGS MODULE Report Headings Write Report Headings Get Date Write Date LineCt=6 Column Headings Exit

  17. ALGORITHM AND FLOWCHART FOR COLUMN HEADINGS MODULE Column Headings 1.Write Column Headings (including the space before and after) 2.LineCt=LineCt+3 3.Exit. Column Headings Write Column Headings LineCt= LineCt+3 Exit

  18. ALGORITHM AND FLOWCHART FOR CALC MODULE CALC 1.SalesTotal=Sales Total +Sales 2.Exit Calc Sales Total=SalesTotal+Sales EXit

  19. ALGORITHM AND FLOWCHART FOR PRINT MODULE Print If LineCt>= MaxLineCt PageBreak Print 1.IF LineCt>=MaxLineCt Then Process Page Break 2.Write Record Information 3.LineCt=LineCt+1 4.Exit T F Write RECORD Information LineCt= LineCt+1 Exit

  20. ALGORITHM AND FLOWCHART FOR PAGEBREAK MODULE Page break • Page break • PageNo=PageNo+1 • Write Page Headings • LineCt=3 • Process Column headings • Exit Eject page PageNo= PageNo+1 Write Page Headings LineCt=3 Column Headings Exit

  21. ALGORITHM AND FLOWCHART FOR WRAP-UPMODULE Wrap Up 1.Write Sales Total 2.Close 1 3.Print “Run Completed” 4.Exit Wrap up WRITE Sales Total Close 1 Print “Run Completed” Exit

  22. Control Breaks Control breaks are used to give subtotals for a group of similar records Multiple Control Breaks Multiple Control Breaks involve subtotals on more than one field. Error Handling For data validation, finding errors in the data records. Null Files Another problem that arises when you are working with files is to how to deal with the empty file or null file.

More Related