Programming Logic and Design Eighth Edition

Slides:



Advertisements
Similar presentations
Chapter 2.7 Data management.
Advertisements

1 Chapter 2 The Digital World. 2 Digital Data Representation.
Chapter 9: Advanced Array Manipulation
MODULE 4 File and Folder Management. Creating file and folder A computer file is a resource for storing information, which is available to a computer.
Programming Logic and Design Fourth Edition, Introductory
Programming Logic and Design, Second Edition, Comprehensive
Chapter 7: Control Breaks Programming Logic and Design, Third Edition Comprehensive.
Programming Logic and Design Fourth Edition, Introductory
Computer Architecture. Central Processing Unit (CPU)- micro processor The Personal Computer.
Writing a Complete Program
Chapter 12 File Management Systems
Modules, Hierarchy Charts, and Documentation
Chapter 8: I/O Streams and Data Files. In this chapter, you will learn about: – I/O file stream objects and functions – Reading and writing character-based.
Programming Logic and Design Fourth Edition, Comprehensive
Programming Logic and Design Fourth Edition, Introductory
MIS316 – BUSINESS APPLICATION DEVELOPMENT – Chapter 14 – Files and Streams 1Microsoft Visual C# 2012, Fifth Edition.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Microsoft Office Illustrated Fundamentals Unit B: Understanding File Management.
Chapter 07 Control Breaks.
Programming Logic and Design Seventh Edition
1 Chapter 12 File Management Systems. 2 Systems Architecture Chapter 12.
Chapter 13 Sequential File Processing. Master Files Set of files used to store companies data in areas like payroll, inventory Usually processed by batch.
The Fun That Is File Structures Pages By: Christine Zeitschel.
1 Introduction to Computers Lect 1 Won’t tell you much you don’t know. (Misleading– the course gets more conceptual as we create webpages.) Will go into.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 6: Sequential Data Files.
File Structures Foundations of Computer Science  Cengage Learning.
Chapter 11 File Systems and Directories. 2 File Systems File: A named collection of related data. File system: The logical view that an operating system.
Data Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
File Handling and Control Break Logic. Objectives In this chapter, you will learn about: Computer files Writing a program that reads from and/or writes.
Now, please open your book to page 60, and let’s talk about chapter 9: How Data is Stored.
Computer Programming TCP1224 Chapter 13 Sequential File Access.
What does a computer do? Accepts data through inputting Processes data
Chapter 14: Files and Streams. 2Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes Temporary storage – Usually called computer.
System design : files. Data Design Concepts  Data Structures  A file or table contains data about people, places or events that interact with the system.
Computers - The Journey Inside continues…
Introduction to Files in VB Chapter 9.1, 9.3. Overview u Data Files  random access  sequential u Working with sequential files  open, read, write,
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
Chapter 11: Sequential File Merging, Matching, and Updating Programming Logic and Design, Third Edition Comprehensive.
11 Chapter 111 Sequential File Merging, Matching, and Updating Programming Logic and Design, Second Edition, Comprehensive 11.
DATA MANAGEMENT 1) File StructureFile Structure 2) Physical OrganisationPhysical Organisation 3) Logical OrganisationLogical Organisation 4) File OrganisationFile.
Java Programming, Second Edition Chapter Sixteen File Input and Output.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
SVBIT SUBJECT:- Operating System TOPICS:- File Management
PCs ENVIRONMENT and PERIPHERALS Lecture 3. operating system and other system software that control the usage of the computer equipment application programs.
( ) 1 Chapter # 8 How Data is stored DATABASE.
Computers Mrs. Flowers University High School.
Computer Graphics HARDWARE. Computers  Computers are automatic, electronic machines that –accept data & instructions from a user (INPUT) –store the data.
Computer Performance & Storage Devices Computer Technology #2.
Chapter 1: Introduction to Computers and Programming
Chapter 6: Sequential Data Files
CHP - 9 File Structures.
Microsoft Windows 7 - Illustrated
Introduction to Transaction Processing
Ch. 8 File Structures Sequential files. Text files. Indexed files.
CSCI 161: Introduction to Programming
Starting Out with Programming Logic & Design
Chapter 13: File Input and Output
Introduction to Computing Lecture # 1
Chapter 1: Introduction to Computers and Programming
Chapter 11-Business and Technology
FILE ORGANIZATION.
Chapter 3 The DATA DIVISION.
Programming Logic and Design Fourth Edition, Comprehensive
Introduction to Computers
Writing a Complete Program
Computer Performance & Storage Devices
CHAPTER 6 ELECTRONIC DATA PROCESSING SYSTEMS
Microsoft Office Illustrated Fundamentals
Chapter 4: Writing and Designing a Complete Program
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Programming Logic and Design Eighth Edition Chapter 7 File Handling and Applications

Objectives In this chapter, you will learn about: Computer files The data hierarchy Performing file operations Control break logic Merging files Master and transaction file processing Random access files Programming Logic and Design, Eighth Edition

Understanding Computer Files A collection of data stored on permanent storage devices such as your computer’s hard drive, a hard drive on the cloud, DVDs, USB drives, and reels of magnetic tape Text files (numbers, names, salaries) that can be read by a text editor Binary files (images and music) File size measured in bytes Byte (one character), kilobyte (thousands of bytes), megabyte (millions of bytes), gigabyte (billions of bytes), terabyte (trillions of bytes) Programming Logic and Design, Eighth Edition

Understanding Computer Files (continued) Figure 7-1 Three stored files showing their names, dates of modification, type, and sizes Programming Logic and Design, Eighth Edition

Understanding Computer Files (continued) Organizing files Directories and folders Organization units on storage devices Path Combination of disk drive plus the complete hierarchy of directories Example: C:\Logic\SampleFiles\PayrollData.dat Programming Logic and Design, Eighth Edition

Understanding the Data Hierarchy Describes the relationships between data components Consists of: Characters – Letters number and special symbols Fields – Data items representing a single attribute of a record Records – Groups of fields that go together for some logical reason Files – Groups of related records Programming Logic and Design, Eighth Edition

Performing File Operations Use data files in your programs Declaring a file identifier InputFile employeeData OutputFile updatedData Opening a file open employeeData "EmployeeData.dat" Reading from a file and processing the data input name from employeeData input address from employeeData input payRate from employeeData Programming Logic and Design, Eighth Edition

Performing File Operations (continued) Figure 7-2 How employee data in a readable comma-delimited file might appear in a text reader Programming Logic and Design, Eighth Edition

Performing File Operations (continued) Figure 7-3 Reading three data items from a storage device into memory Programming Logic and Design, Eighth Edition

Performing File Operations (continued) Sequential file Program reads all the records in this file from beginning to end, processing them one t a time Sorting The process of placing records in order by the value in a specific field or fields Writing data to a file output name, address, payRate to employeeData Closing a file Always close every file you open Programming Logic and Design, Eighth Edition

A Program that Performs File Operations Figure 7-4 Flowchart and pseudocode for a program that uses files (Continues) Programming Logic and Design, Eighth Edition

A Program that Performs File Operations (continued) Backup file - a copy kept in case values need to be restored to their original state The backup copy is called a parent file and the newly revised copy is a child file Figure 7-4 Flowchart and pseudocode for a program that uses files (continued) Programming Logic and Design, Eighth Edition

Understanding Control Break Logic A control break is a temporary detour in the logic of a program A control break program uses a change in a value to initiate special actions or processing A control break report groups similar data together Input records must be in sequential order Programming Logic and Design, Eighth Edition

Understanding Sequential Files and Control Break Logic (continued) Figure 7-5 A control break report with totals after each state Programming Logic and Design, Eighth Edition

Understanding Control Break Logic (continued) Examples of control break reports All employees listed in order by department number, with a new page started for each department All books for sale in a bookstore listed in order by category (such as reference or self-help), with a count following each category of book All items sold in order by date of sale, with a different ink color for each new month Programming Logic and Design, Eighth Edition

Understanding Control Break Logic (continued) Single-level control break A detour based on the value of a single variable Uses a control break field to hold the previous value Programming Logic and Design, Eighth Edition

Understanding Control Break Logic (continued) Figure 7-6 Mainline logic and getReady() module for the program that produces clients by state report Programming Logic and Design, Eighth Edition

Understanding Control Break Logic (continued) Figure 7-7 The produceReport() and controlBreak() modules for the program that produces clients by state Programming Logic and Design, Eighth Edition

Understanding Control Break Logic (continued) Figure 7-8 The finishUp()module for the program that produces clients by state report Programming Logic and Design, Eighth Edition

Merging Sequential Files Merging files Combining two or more files while maintaining the sequential order Examples A file of current employees in ID number order, and a file of newly hired employees also in ID number order A file of parts manufactured in the Northside factory in part-number order, and a file of parts manufactured in the Southside factory also in part-number order Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Two conditions required for merging files Each file has the same record layout Sorted in the same order based on the same field Ascending order (lowest to highest values) Descending order (highest to lowest values) Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Figure 7-9 Sample data contained in two customer files Figure 7-10 Merged customer file Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Mainline logic similar to other file-processing programs, except for handling two files With two input files, must determine when both files are at eof Define a flag variable to indicate that both files have reached eof Must define two input files Read one record from each input file Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Figure 7-11 Mainline logic of a program that merges files Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Figure 7-12 The getReady() method for a program that merges files, and the methods it calls (Continues) Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Figure 7-12 The getReady() method for a program that merges files, and the methods it calls Programming Logic and Design, Eighth Edition

Merging Sequential Files (continued) Programming Logic and Design, Eighth Edition Figure 7-13 Start of merging process

Merging Sequential Files (continued) Programming Logic and Design, Eighth Edition Figure 7-14 Continuation of merging process

Merging Sequential Files (continued) Figure 7-15 The mergeRecords() and finishUp() modules for the file-merging program Programming Logic and Design, Eighth Edition

Master and Transaction File Processing Some related files have a master-transaction relationship Master file Holds complete and relatively permanent data Transaction file Contains temporary data to be used to update the master file Update the master file Changes to values in its fields based on transactions Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Examples A library maintains a master file of all patrons and a transaction file with information about each book or other items checked out A college maintains a master file of all students and a transaction file for each course registration A telephone company maintains a master file of every telephone line (number) and a transaction file with information about every call Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Updating approaches Change information in master file Copy master file and change new version Begin with both files sorted in the same order on the same field Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Figure 7-16 Mainline logic for the master-transaction program Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Figure 7-17 The housekeeping() module for the master-transaction program, and the modules it calls (Continues) Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Figure 7-17 The housekeeping() module for the master-transaction program, and the modules it calls Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Figure 7-18 The updateRecords() module for the master-transaction program Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Figure 7-19 Sample data for the file-matching program Programming Logic and Design, Eighth Edition

Master and Transaction File Processing (continued) Figure 7-20 The finishUp() module for the master-transaction program Programming Logic and Design, Eighth Edition

Random Access Files Batch processing Real-time applications Involves performing the same tasks with many records, one after the other Uses sequential files Real-time applications Require that a record be accessed immediately while a client is waiting Interactive program A program in which the user makes direct requests Programming Logic and Design, Eighth Edition

Random Access Files (continued) Records can be located in any order Instant access files Locating a particular record directly Also known as direct access files Programming Logic and Design, Eighth Edition

Random Access Files (continued) Figure 7-21 Accessing a record in a sequential file and in a random access file Programming Logic and Design, Eighth Edition

Summary Computer file Data items are stored in a hierarchy A collection of data stored on a nonvolatile device in a computer system Data items are stored in a hierarchy Using a data file Declare, open, read, write, close Sequential file: records stored in some order Merging files combines two or more files Maintains the same sequential order Programming Logic and Design, Eighth Edition

Summary Master files Real-time applications Hold permanent data Updated by transaction files Real-time applications Require random access files Records stored in any order Records accessed immediately Programming Logic and Design, Eighth Edition