Presentation is loading. Please wait.

Presentation is loading. Please wait.

 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.

Similar presentations


Presentation on theme: " 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."— Presentation transcript:

1  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. FILE CONCEPTS

2 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. 1.Open LFN: It tells the computer that the data in the file called filename is to be used, starting at the first record. 2.Read LFN Record copies the next record into the internal memory or into a small holding memory called buffer memory. 3.Close LFN It tells the computer that the file will not be used anymore.

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

4 Process Module Automatic- counter loop Flowchart Symbols counter AB S

5 System Flowcharts 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. KEYBOARD MONITOR PROGRAM DISK DRIVE PRINTER

6 EXAMPLE OF A SYSTEMFLOWCHART MASTER FILE REPORT PROCESSPROGRAM NEW FILE

7 DESIGNING RECORDS FILENAME:MAILING LIST Field Number Item Description Field Name Field Length Data type # of Decimal Comment 1Last NameLNameln15C 2FirstNameFNameln10C 3Street address StAddress ln 20C 4CityCityln20C 5StateStateln2C 6ZipcodeZipCodeln10C 7Telephone number Telenoln12C RECORD DATA DICTIONARY

8 RECORD LAYOUT 1 LNameIn 15 16 LNameIn 25 26 StAddressln 45 46 Cityln 65 66 Statel n 67 68 ZipCodeln 77 78 Telenoln 89

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 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 Control Init While Not EOF(1) Calc Print Read Wrap up End F T

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 Read PageNo=1 Report Headings Max Line Ct = 60 Sales Total=0 Exit

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

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 LineCt=6 Column Headings Write Date Get Date Exit Write Report Headings

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 Print 1.IF LineCt>=MaxLineCt Then Process Page Break 2.Write Record Information 3.LineCt=LineCt+1 4.Exit Print If LineCt>= MaxLineCt Write RECORD Information LineCt= LineCt+1 Exit PageBreak T F ALGORITHM AND FLOWCHART FOR PRINT MODULE

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

21 ALGORITHM AND FLOWCHART FOR WRAP- UPMODULE Wrap Up 1.Write Sales Total 2.Close 1 3.Print “Run Completed” 4.Exit WRITE Sales Total Close 1 Print “Run Completed” Wrap up 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.


Download ppt " 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."

Similar presentations


Ads by Google