0% found this document useful (0 votes)
22 views15 pages

Lecture 4.Pptx 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views15 pages

Lecture 4.Pptx 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

NEHRU ARTS AND SCIENCE COLLEGE

COIMBATORE -641 105

DEPARTMENT OF INFORMATION TECHNOLOGY


Course: Data Structures

Facilitator : Dr.S.Saraswathi
Files
Introduction
• A file is a container in a computer system for storing information.

• Files used in computers are similar in features to that of paper


documents used in library and office files.

• There are different types of files such as text files, data files,
directory files, binary and graphic files

• In a computer operating system, files can be stored on optical drives,


hard drives or other types of storage devices.
• File is a collection of records where each record consist of one or
more fields.

• For eg: Records in an employee file contains,

employeeno, employeename, occupation, gender, location, salary

employeenam
employeeno occupation gender location salary
e
7369 SMITH CLERK F Production Unit 800.00

7499 ALLEN SALESMAN M Dispatch Unit 1600.00

7521 WARD SALESMAN M Purchase Unit 1250.00

7566 JONES MANAGER F Control Unit 2975.00


• File organization is to provide a direction to retrieve and update the
records.

• Updation includes deletion,changes and insertion of new records.

• Certain fields in the record are key fields used to identify the records and
called as unique key.

• A combination of key values specified for retrieval will be termed as Query.

Some valid queries:


• Q1 : Gender = M
• Q2 : Salary > 500
• Q3 : Gender = M and Occupation = Salesman
Storage Device Types
Direct Access Storage Devices ( DASD) – Disk and Tape.
Query Types
Four Types:
1. Simple Query : The value of a single key is specified.

2. Range Query : A range of values for a single key is specified.

3. Functional Query : Function of key values in the file is specified.

Eg: Average or Mean

4. Boolean Query : A Boolean combination of Q1 – Q3 using logical operators.


Number of Keys
• Files with one key

• Files with more than one key

Mode of Retrieval ( Real Time and Batched )

In real time retrieval, the response time of any query should be minimal.

Eg : Checking the balance in a bank account

In batched retrieval, the response time is not significant.

Eg : Request a transaction file


Mode of Update ( Real Time and Batched )
• Real time update is needed – Eg : Reservation system

• Batched update would be suitable in a bank account system

There are two files in a batched update : Master and Transaction File
• Master File represents the file status after the previous update.

• Transaction file represents all until it represents in master file.

All the required functions can be carried out efficiently by maintaining the
master file on a tape.
• The records in the file are ordered by a key field.
• Request for retrieval and update are batched on to a transaction
tape.
Sequential Order
• The records in the transactions are sorted using the sorted file and
master files are examined when updates are processed.

• Time required for the process is O(n + m log m) where n and m are
the records in master and transaction files.

• Records are organized sequentially on to the storage media.


• Primary key is used to order the physical sequence of the records.

• Eg : Student Roll No, Employee Id , Patient Id

• Sequential organization is suitable for disk also.

• Even though disk storage is two dimensional and mapped to one


dimensional memory.

• Disk has c cylinders and s surfaces , the sequence is tij to represent


the jth track of ith surface, t1,1,t2,1,t3,1 …….
•Its main advantages are:
• It is easy to implement;
• It provides fast access to the next record using lexicographic order.
•Its disadvantages:
• It is difficult to update - inserting a new record may require moving
a large proportion of the file;
• Random access is extremely slow.
• Storing and sorting in contiguous block within files on tape or disk is
called as sequential access file organization.

• In sequential access file organization, all records are stored in a


sequential order. The records are arranged in the ascending or
descending order of a key field.

• Sequential file search starts from the beginning of the file and the
records can be added at the end of the file.

• In sequential file, it is not possible to add a record in the middle of the


file without rewriting the file.
The basic operations that can be performed on a file are:
• Creation of a new file

• Modification of data or file attributes

• Reading of data from the file

• Opening the file in order to make the contents available


to other programs

• Writing data to the file

• Closing or terminating a file operation


Thank you

You might also like