File organization

K
File Organization
Prepared By
Ms. K. D. Patil, AP
Department of Information Technology
Sanjivani College of Engineering, Kopargaon
Logical vs. Physical Organization
of Data
• logical organization
• the abstract way that the computer
program is able to access the data
• use of logical structures (e.g. linked lists)
• physical organization
• the actual physical structure of data in
memory
• i.e. what the sequence of bits look like in
memory
Definitions
• database
– collection of related files
• file
– collection of related records
• record
– collection of related fields (e.g. Name, Age)
• key field
– uniquely identifies a record (e.g. UserID)
Taxonomy of file structures
• One record after another,
from beginning to end
Access one specific record without having
to retrieve all records before
Basics
• Records are stored at different places (different
indices or locations)
• The access method determines how records
can be retrieved: sequentially or randomly.
• To find a record, we need to know its location
• We can search for the record
OR
• Jump to its location directly (if location is known)
OR
• A combination of jumping and searching
Sequential File Organization
• Suitable for applications that
require sequential processing
of the entire file
• The records in the file are
ordered by a search-key
• Originally designed to
operate on magnetic tapes
• records can only be accessed sequentially, one
after another, from beginning to end.
Sequential File Organization
• Deletion – use pointer chains
• Insertion –locate the position
where the record is to be inserted
– if there is free space insert there
– if no free space, insert the record
in an overflow block
– In either case, pointer chain
must be updated
• Need to reorganize the file
from time to time to restore
sequential order
Updating sequential files
• sequential files must be updated periodically to
reflect changes in information.
• The updating process –
all of the records need to be checked and updated
(if necessary) sequentially.
– New Master File
– Old Master File
– Transaction File –
contains changes to be applied to the master file.
• Add transaction
• Delete transaction
• Change transaction
• A key is one or more fields that uniquely identify the data in
the file.
– Error Report File
Updating sequential files
Updating sequential files
• To make updating process efficient, all files are
sorted on the same key.
• The update process requires that you compare :
[transaction file key] vs. [old master file key]
– < : add transaction to new master
– = :
• Change content of master file data (transaction code =
R(revise) )
• Remove data from master file (transaction code = D(delete) )
– > : write old master file record to new master file
(transaction code = A(add) )
Rename and Remove
• Remove(filename)
– This function is used to remove any file
from the record. Use one argument that is
name of the file which we want to delete.
• Rename(oldname,newname)
– This function is used to rename any file.
Takes two arguments. Old file name and
New name of the file.
Advantages
• If the order in which you keep records in a file is not
important, sequential organization is a good choice
whether there are many records or only a few.
Sequential output is also useful for printing reports.
• Reading of records in order of the ordering key is
extremely efficient.
• Finding the next record in order of the ordering key
usually, does not require additional block access.
Moreover, Next record may found in the same block.
• Moreover, Searching operation on ordering key is must
faster. Binary search can utilize. Also, A binary search
will require log2b block accesses where b is the total
number of blocks in the file
• It is simple to program and easy to design.
• Sequential file is best use if storage space.
Disadvantages
• The sequential file does not give any advantage when the
search operation is to carry out in non- ordering field.
• Inserting a record is an expensive operation. Insertion of a
new record requires the finding of a place of insertion and
then all records ahead of it must move to create space for
the record to insert. Moreover, This could be very expensive
for large files.
• Moreover, Deleting a record is an expensive operation. So,
Deletion too requires movement of records.
• Modification of field value of ordering key could time-
consuming. Also, Modifying the ordering field means the
record can change its position. This requires deletion of the
old record followed by insertion of the modified record.
• Sequential file is time consuming process.
• It has high data redundancy.
• Random searching is not possible.
Applications
• Reading the magnetic tape
Random Access File
Organization
• Direct access file is also known as random
access or relative file organization.
• In direct access file, all records are stored in
direct access storage device (DASD), such as
hard disk. The records are randomly placed
throughout the file.
• The records does not need to be in sequence
because they are updated directly and
rewritten back in the same location.
• This file organization is useful for immediate
access to large amount of information. It is
used in accessing large databases.
• It is also called as hashing.
Random Access File
Organization
 A hashed file uses a hash function
to map the key to the address.
 Eliminates the need for an extra file
(index).
 There is no need for an index and all
of the overhead associated with it.
Functions
Function Syntax Explaination
seekg()
Fileobj.seekg(longnum,
origin)
We can move input file pointer to a
specific location using this function.
Fileobj is the pointer to the file that
we want to access and longnum is
the number of bytes we want to
skip. Origin is the value that tells
compiler where to begin skipping of
bytes.
seekp()
Fileobj.seekp(longnum,
origin)
We can move output file pointer to
a specific location using this
function. Same as seekg but
works for writing.
tellg() Fileobj.tellg( )
Return the current position of input
pointer.
tellp() Fileobj.tellp( )
Return the current position of
output pointer.
Flag Modes of Seek()
Mode Flag Description
ios::beg
The offset is calculated from
the beginning of the file.
ios::end
The offset is calculated from
the end of the file.
ios::cur
The offset is calculated from
the current position.
Flag Modes of Seek()
• Both istream and ostream provide member
functions for repositioning the file-position pointer.
These member functions are seekg ("seek get") for
istream and seekp ("seek put") for ostream.
• The argument to seekg and seekp normally is a
long integer. A second argument can be specified
to indicate the seek direction. The seek direction
can be ios::beg (the default) for positioning relative
to the beginning of a stream, ios::cur for positioning
relative to the current position in a stream or
ios::end for positioning relative to the end of a
stream.
Advantages
• Direct access file helps in online
transaction processing system (OLTP) like
online railway reservation system.
• In direct access file, sorting of the records
are not required.
• It accesses the desired records
immediately.
• It updates several files quickly.
• It has better control over record allocation.
Disadvantages
• Direct access file does not provide
back up facility.
• It is expensive.
• It has less storage space as
compared to sequential file.
Applications
• Credit card companies uses Random
Access so their computers directly go
to our record
Indexed sequential access file
organization
• Indexed sequential access file combines both
sequential file and direct access file organization.
• In indexed sequential access file, records are
stored randomly on a direct access device such
as magnetic disk by a primary key.
• This file have multiple keys. These keys can be
alphanumeric in which the records are ordered is
called primary key.
• The data can be access either sequentially or
randomly using the index. The index is stored in
a file and read into memory when the file is
opened.
Advantages
• In indexed sequential access file, sequential
file and random file access is possible.
• It accesses the records very fast if the index
table is properly organized.
• The records can be inserted in the middle of
the file.
• It provides quick access for sequential and
direct processing.
• It reduces the degree of the sequential
search.
Disadvantages
• Indexed sequential access file requires
unique keys and periodic reorganization.
• Indexed sequential access file takes
longer time to search the index for the
data access or retrieval.
• It requires more storage space.
• It is expensive because it requires
special software.
• It is less efficient in the use of storage
space as compared to other file
organizations.
Partially-Indexed Sequential Files
Key Record
Address
A 1
B 6
C 11
D 16
Record
1
2
3
4
5
6
7
8
9
10
11
12
Fully Indexed Files
• Every record has an index (address)
• Sequentially search through key field
for specific record address
• Records may be accessed directly OR
in sequential order by address
Fully Indexed Files
Key Record
Address
a 4
b 7
c 5
d 3
e 12
m 9
n 10
p 2
s 11
t 6
z 1
Applications
• ISAM (Indexed Sequential Access Method) is a file
management system developed at IBM that allows 
records to be accessed either sequentially (in the
order they were entered) or randomly (with an index).
Each index defines a different ordering of the records.
An employee database may have several indexes,
based on the information being sought. For example, a
name index may order employees alphabetically by
last name, while a department index may order
employees by their department. A key is specified in
each index. For an alphabetical index of employee
names, the last name field would be the key.
Application
• Indexed sequential files are used when it is
necessary to use
both indexed and sequential access. A
company might store an employee file as an
indexed sequential file, because...
• Sometimes only one record needs to be
accessed ...
... an employee changes their address...
... use indexed access.
• Sometimes all records need to be accessed...
... the end-of-month payroll is run...
... use sequential access.
Comparison
Sequential File Index File Relative/Random File
Data is entered in
entry sequential
order
Data is entered in key
sequential order
Data is entered in RRN
number
Duplicate data is
allowed
Duplicate data is not
allowed
Duplicate data is
notallowed
Data is in sorted
order
Data is in sorted order
based on key
Data is in sorted order
based on RRN
Delete is not
applicable
Delete is applicable Delete is applicable
Access is slow Access is faster
Access is faster than
index files
Key not available
Key is available. Key is
user defined. It is a part
of record.
Key is available. Key is
system defined. It is
outside of record.
Data is stored on
tape/Disk
Data is stored on disk
only
Data is stored on disk
only
Frequently used Rarely used Not yet all used
1 de 31

Recomendados

File organization por
File organizationFile organization
File organizationRituBhargava7
6.6K vistas24 diapositivas
File Organization por
File OrganizationFile Organization
File OrganizationManyi Man
24.6K vistas17 diapositivas
File organisation por
File organisationFile organisation
File organisationMukund Trivedi
46.6K vistas30 diapositivas
File organization por
File organizationFile organization
File organizationGanesh Pawar
9.3K vistas18 diapositivas
Transaction processing ppt por
Transaction processing pptTransaction processing ppt
Transaction processing pptJaved Khan
9.2K vistas17 diapositivas
File organization 1 por
File organization 1File organization 1
File organization 1Rupali Rana
14.9K vistas40 diapositivas

Más contenido relacionado

La actualidad más candente

Database System Architectures por
Database System ArchitecturesDatabase System Architectures
Database System ArchitecturesInformation Technology
14.7K vistas37 diapositivas
Transaction management DBMS por
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMSMegha Patel
16.2K vistas20 diapositivas
Distributed database por
Distributed databaseDistributed database
Distributed databaseReachLocal Services India
63.9K vistas27 diapositivas
File organization por
File organizationFile organization
File organizationComputer Hardware & Trouble shooting
46.5K vistas23 diapositivas
File organisation por
File organisationFile organisation
File organisationSamuel Igbanogu
10.5K vistas31 diapositivas
File access methods.54 por
File access methods.54File access methods.54
File access methods.54myrajendra
24.8K vistas26 diapositivas

La actualidad más candente(20)

Transaction management DBMS por Megha Patel
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
Megha Patel16.2K vistas
File access methods.54 por myrajendra
File access methods.54File access methods.54
File access methods.54
myrajendra24.8K vistas
Data mining & data warehousing (ppt) por Harish Chand
Data mining & data warehousing (ppt)Data mining & data warehousing (ppt)
Data mining & data warehousing (ppt)
Harish Chand20.6K vistas
15. Transactions in DBMS por koolkampus
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus80.4K vistas
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA por Saikiran Panjala
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALADATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
DATA WAREHOUSE IMPLEMENTATION BY SAIKIRAN PANJALA
Saikiran Panjala4.4K vistas
NOSQL- Presentation on NoSQL por Ramakant Soni
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
Ramakant Soni28.2K vistas
database recovery techniques por Kalhan Liyanage
database recovery techniques database recovery techniques
database recovery techniques
Kalhan Liyanage57.8K vistas
Slide 4 dbms users por Visakh V
Slide 4 dbms usersSlide 4 dbms users
Slide 4 dbms users
Visakh V4.9K vistas
12. Indexing and Hashing in DBMS por koolkampus
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
koolkampus66.8K vistas
Relational database por Megha Sharma
Relational database Relational database
Relational database
Megha Sharma1.1K vistas
Overview of physical storage media por Srinath Sri
Overview of physical storage mediaOverview of physical storage media
Overview of physical storage media
Srinath Sri10.8K vistas
Database recovery por Student
Database recoveryDatabase recovery
Database recovery
Student657 vistas

Similar a File organization

FIle Organization.pptx por
FIle Organization.pptxFIle Organization.pptx
FIle Organization.pptxSreenivas R
3 vistas46 diapositivas
fileorganizationandintroductionofdbms-210313163900.pdf por
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdfFraolUmeta
12 vistas74 diapositivas
File organization and introduction of DBMS por
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMSVrushaliSolanke
424 vistas74 diapositivas
Wk 1 - File organization.pptx por
Wk 1 - File organization.pptxWk 1 - File organization.pptx
Wk 1 - File organization.pptxDORCASGABRIEL1
96 vistas36 diapositivas
File organisation in system analysis and design por
File organisation in system analysis and designFile organisation in system analysis and design
File organisation in system analysis and designMohitgauri
6K vistas30 diapositivas
File Structure.pptx por
File Structure.pptxFile Structure.pptx
File Structure.pptxzedd15
6 vistas22 diapositivas

Similar a File organization(20)

FIle Organization.pptx por Sreenivas R
FIle Organization.pptxFIle Organization.pptx
FIle Organization.pptx
Sreenivas R3 vistas
fileorganizationandintroductionofdbms-210313163900.pdf por FraolUmeta
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdf
FraolUmeta12 vistas
File organization and introduction of DBMS por VrushaliSolanke
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
VrushaliSolanke424 vistas
File organisation in system analysis and design por Mohitgauri
File organisation in system analysis and designFile organisation in system analysis and design
File organisation in system analysis and design
Mohitgauri6K vistas
File Structure.pptx por zedd15
File Structure.pptxFile Structure.pptx
File Structure.pptx
zedd156 vistas
File management in OS por Bhavik Vashi
File management in OSFile management in OS
File management in OS
Bhavik Vashi239 vistas
2.7 Use of ICT in Data Management por Momina Mateen
2.7 Use of ICT in Data Management2.7 Use of ICT in Data Management
2.7 Use of ICT in Data Management
Momina Mateen7.6K vistas
Data Indexing Presentation-My.pptppt.ppt por sdsm2
Data Indexing Presentation-My.pptppt.pptData Indexing Presentation-My.pptppt.ppt
Data Indexing Presentation-My.pptppt.ppt
sdsm23 vistas
overview of storage and indexing BY-Pratik kadam por pratikkadam78
overview of storage and indexing BY-Pratik kadam overview of storage and indexing BY-Pratik kadam
overview of storage and indexing BY-Pratik kadam
pratikkadam7828 vistas
File organisation por Suneel Dogra
File organisationFile organisation
File organisation
Suneel Dogra4.5K vistas
Roaring with elastic search sangam2018 por Vinay Kumar
Roaring with elastic search sangam2018Roaring with elastic search sangam2018
Roaring with elastic search sangam2018
Vinay Kumar500 vistas
Csci12 report aug18 por karenostil
Csci12 report aug18Csci12 report aug18
Csci12 report aug18
karenostil290 vistas
File system in operating system e learning por Lavanya Sharma
File system in operating system e learningFile system in operating system e learning
File system in operating system e learning
Lavanya Sharma412 vistas

Más de KanchanPatil34

Unit 2_2 Binary Tree as ADT_General Tree.pdf por
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfKanchanPatil34
4 vistas26 diapositivas
Unit 2_1 Tree.pdf por
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdfKanchanPatil34
16 vistas39 diapositivas
Unit 2_3 Binary Tree Traversals.pdf por
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfKanchanPatil34
5 vistas33 diapositivas
Unit 1_SLL and DLL.pdf por
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfKanchanPatil34
3 vistas45 diapositivas
Unit 1_Stack and Queue using Linked Organization.pdf por
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfKanchanPatil34
2 vistas40 diapositivas
PAI Unit 3 Paging in 80386 Microporcessor por
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorKanchanPatil34
1.1K vistas21 diapositivas

Más de KanchanPatil34(20)

Unit 2_2 Binary Tree as ADT_General Tree.pdf por KanchanPatil34
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdf
KanchanPatil344 vistas
Unit 2_3 Binary Tree Traversals.pdf por KanchanPatil34
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdf
KanchanPatil345 vistas
Unit 1_Stack and Queue using Linked Organization.pdf por KanchanPatil34
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
KanchanPatil342 vistas
PAI Unit 3 Paging in 80386 Microporcessor por KanchanPatil34
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
KanchanPatil341.1K vistas
PAI Unit 3 Multitasking in 80386 por KanchanPatil34
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386
KanchanPatil341.1K vistas
PAI Unit 2 Segmentation in 80386 microprocessor por KanchanPatil34
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessor
KanchanPatil34425 vistas
PAI Unit 2 Protection in 80386 segmentation por KanchanPatil34
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
KanchanPatil34456 vistas
SE PAI Unit 2_Data Structures in 80386 segmentation por KanchanPatil34
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentation
KanchanPatil3455 vistas
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1 por KanchanPatil34
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
KanchanPatil3455 vistas
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2 por KanchanPatil34
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
KanchanPatil3462 vistas
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3 por KanchanPatil34
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
KanchanPatil3464 vistas
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2 por KanchanPatil34
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
KanchanPatil3451 vistas
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1 por KanchanPatil34
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
KanchanPatil3466 vistas
SE PAI Unit 5_IO programming in 8051 por KanchanPatil34
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051
KanchanPatil3457 vistas
Unit 5_Interrupt programming in 8051 micro controller - part 2 por KanchanPatil34
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2
KanchanPatil3455 vistas
Unit 5_interrupt programming_Part 1 por KanchanPatil34
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
KanchanPatil3468 vistas

Último

MSA Website Slideshow (16).pdf por
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdfmsaucla
39 vistas8 diapositivas
7_DVD_Combinational_MOS_Logic_Circuits.pdf por
7_DVD_Combinational_MOS_Logic_Circuits.pdf7_DVD_Combinational_MOS_Logic_Circuits.pdf
7_DVD_Combinational_MOS_Logic_Circuits.pdfUsha Mehta
50 vistas133 diapositivas
Informed search algorithms.pptx por
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptxDr.Shweta
12 vistas19 diapositivas
NEW SUPPLIERS SUPPLIES (copie).pdf por
NEW SUPPLIERS SUPPLIES (copie).pdfNEW SUPPLIERS SUPPLIES (copie).pdf
NEW SUPPLIERS SUPPLIES (copie).pdfgeorgesradjou
7 vistas30 diapositivas
Electronic Devices - Integrated Circuit.pdf por
Electronic Devices - Integrated Circuit.pdfElectronic Devices - Integrated Circuit.pdf
Electronic Devices - Integrated Circuit.pdfbooksarpita
11 vistas46 diapositivas
Dynamics of Hard-Magnetic Soft Materials por
Dynamics of Hard-Magnetic Soft MaterialsDynamics of Hard-Magnetic Soft Materials
Dynamics of Hard-Magnetic Soft MaterialsShivendra Nandan
13 vistas32 diapositivas

Último(20)

MSA Website Slideshow (16).pdf por msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msaucla39 vistas
7_DVD_Combinational_MOS_Logic_Circuits.pdf por Usha Mehta
7_DVD_Combinational_MOS_Logic_Circuits.pdf7_DVD_Combinational_MOS_Logic_Circuits.pdf
7_DVD_Combinational_MOS_Logic_Circuits.pdf
Usha Mehta50 vistas
Informed search algorithms.pptx por Dr.Shweta
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta12 vistas
NEW SUPPLIERS SUPPLIES (copie).pdf por georgesradjou
NEW SUPPLIERS SUPPLIES (copie).pdfNEW SUPPLIERS SUPPLIES (copie).pdf
NEW SUPPLIERS SUPPLIES (copie).pdf
georgesradjou7 vistas
Electronic Devices - Integrated Circuit.pdf por booksarpita
Electronic Devices - Integrated Circuit.pdfElectronic Devices - Integrated Circuit.pdf
Electronic Devices - Integrated Circuit.pdf
booksarpita11 vistas
Dynamics of Hard-Magnetic Soft Materials por Shivendra Nandan
Dynamics of Hard-Magnetic Soft MaterialsDynamics of Hard-Magnetic Soft Materials
Dynamics of Hard-Magnetic Soft Materials
Shivendra Nandan13 vistas
A multi-microcontroller-based hardware for deploying Tiny machine learning mo... por IJECEIAES
A multi-microcontroller-based hardware for deploying Tiny machine learning mo...A multi-microcontroller-based hardware for deploying Tiny machine learning mo...
A multi-microcontroller-based hardware for deploying Tiny machine learning mo...
IJECEIAES10 vistas
Extensions of Time - Contract Management por brainquisitive
Extensions of Time - Contract ManagementExtensions of Time - Contract Management
Extensions of Time - Contract Management
brainquisitive15 vistas
Multi-objective distributed generation integration in radial distribution sy... por IJECEIAES
Multi-objective distributed generation integration in radial  distribution sy...Multi-objective distributed generation integration in radial  distribution sy...
Multi-objective distributed generation integration in radial distribution sy...
IJECEIAES15 vistas
An approach of ontology and knowledge base for railway maintenance por IJECEIAES
An approach of ontology and knowledge base for railway maintenanceAn approach of ontology and knowledge base for railway maintenance
An approach of ontology and knowledge base for railway maintenance
IJECEIAES12 vistas
cloud computing-virtualization.pptx por RajaulKarim20
cloud computing-virtualization.pptxcloud computing-virtualization.pptx
cloud computing-virtualization.pptx
RajaulKarim2082 vistas

File organization

  • 1. File Organization Prepared By Ms. K. D. Patil, AP Department of Information Technology Sanjivani College of Engineering, Kopargaon
  • 2. Logical vs. Physical Organization of Data • logical organization • the abstract way that the computer program is able to access the data • use of logical structures (e.g. linked lists) • physical organization • the actual physical structure of data in memory • i.e. what the sequence of bits look like in memory
  • 3. Definitions • database – collection of related files • file – collection of related records • record – collection of related fields (e.g. Name, Age) • key field – uniquely identifies a record (e.g. UserID)
  • 4. Taxonomy of file structures • One record after another, from beginning to end Access one specific record without having to retrieve all records before
  • 5. Basics • Records are stored at different places (different indices or locations) • The access method determines how records can be retrieved: sequentially or randomly. • To find a record, we need to know its location • We can search for the record OR • Jump to its location directly (if location is known) OR • A combination of jumping and searching
  • 6. Sequential File Organization • Suitable for applications that require sequential processing of the entire file • The records in the file are ordered by a search-key • Originally designed to operate on magnetic tapes • records can only be accessed sequentially, one after another, from beginning to end.
  • 7. Sequential File Organization • Deletion – use pointer chains • Insertion –locate the position where the record is to be inserted – if there is free space insert there – if no free space, insert the record in an overflow block – In either case, pointer chain must be updated • Need to reorganize the file from time to time to restore sequential order
  • 8. Updating sequential files • sequential files must be updated periodically to reflect changes in information. • The updating process – all of the records need to be checked and updated (if necessary) sequentially. – New Master File – Old Master File – Transaction File – contains changes to be applied to the master file. • Add transaction • Delete transaction • Change transaction • A key is one or more fields that uniquely identify the data in the file. – Error Report File
  • 10. Updating sequential files • To make updating process efficient, all files are sorted on the same key. • The update process requires that you compare : [transaction file key] vs. [old master file key] – < : add transaction to new master – = : • Change content of master file data (transaction code = R(revise) ) • Remove data from master file (transaction code = D(delete) ) – > : write old master file record to new master file (transaction code = A(add) )
  • 11. Rename and Remove • Remove(filename) – This function is used to remove any file from the record. Use one argument that is name of the file which we want to delete. • Rename(oldname,newname) – This function is used to rename any file. Takes two arguments. Old file name and New name of the file.
  • 12. Advantages • If the order in which you keep records in a file is not important, sequential organization is a good choice whether there are many records or only a few. Sequential output is also useful for printing reports. • Reading of records in order of the ordering key is extremely efficient. • Finding the next record in order of the ordering key usually, does not require additional block access. Moreover, Next record may found in the same block. • Moreover, Searching operation on ordering key is must faster. Binary search can utilize. Also, A binary search will require log2b block accesses where b is the total number of blocks in the file • It is simple to program and easy to design. • Sequential file is best use if storage space.
  • 13. Disadvantages • The sequential file does not give any advantage when the search operation is to carry out in non- ordering field. • Inserting a record is an expensive operation. Insertion of a new record requires the finding of a place of insertion and then all records ahead of it must move to create space for the record to insert. Moreover, This could be very expensive for large files. • Moreover, Deleting a record is an expensive operation. So, Deletion too requires movement of records. • Modification of field value of ordering key could time- consuming. Also, Modifying the ordering field means the record can change its position. This requires deletion of the old record followed by insertion of the modified record. • Sequential file is time consuming process. • It has high data redundancy. • Random searching is not possible.
  • 15. Random Access File Organization • Direct access file is also known as random access or relative file organization. • In direct access file, all records are stored in direct access storage device (DASD), such as hard disk. The records are randomly placed throughout the file. • The records does not need to be in sequence because they are updated directly and rewritten back in the same location. • This file organization is useful for immediate access to large amount of information. It is used in accessing large databases. • It is also called as hashing.
  • 16. Random Access File Organization  A hashed file uses a hash function to map the key to the address.  Eliminates the need for an extra file (index).  There is no need for an index and all of the overhead associated with it.
  • 17. Functions Function Syntax Explaination seekg() Fileobj.seekg(longnum, origin) We can move input file pointer to a specific location using this function. Fileobj is the pointer to the file that we want to access and longnum is the number of bytes we want to skip. Origin is the value that tells compiler where to begin skipping of bytes. seekp() Fileobj.seekp(longnum, origin) We can move output file pointer to a specific location using this function. Same as seekg but works for writing. tellg() Fileobj.tellg( ) Return the current position of input pointer. tellp() Fileobj.tellp( ) Return the current position of output pointer.
  • 18. Flag Modes of Seek() Mode Flag Description ios::beg The offset is calculated from the beginning of the file. ios::end The offset is calculated from the end of the file. ios::cur The offset is calculated from the current position.
  • 19. Flag Modes of Seek() • Both istream and ostream provide member functions for repositioning the file-position pointer. These member functions are seekg ("seek get") for istream and seekp ("seek put") for ostream. • The argument to seekg and seekp normally is a long integer. A second argument can be specified to indicate the seek direction. The seek direction can be ios::beg (the default) for positioning relative to the beginning of a stream, ios::cur for positioning relative to the current position in a stream or ios::end for positioning relative to the end of a stream.
  • 20. Advantages • Direct access file helps in online transaction processing system (OLTP) like online railway reservation system. • In direct access file, sorting of the records are not required. • It accesses the desired records immediately. • It updates several files quickly. • It has better control over record allocation.
  • 21. Disadvantages • Direct access file does not provide back up facility. • It is expensive. • It has less storage space as compared to sequential file.
  • 22. Applications • Credit card companies uses Random Access so their computers directly go to our record
  • 23. Indexed sequential access file organization • Indexed sequential access file combines both sequential file and direct access file organization. • In indexed sequential access file, records are stored randomly on a direct access device such as magnetic disk by a primary key. • This file have multiple keys. These keys can be alphanumeric in which the records are ordered is called primary key. • The data can be access either sequentially or randomly using the index. The index is stored in a file and read into memory when the file is opened.
  • 24. Advantages • In indexed sequential access file, sequential file and random file access is possible. • It accesses the records very fast if the index table is properly organized. • The records can be inserted in the middle of the file. • It provides quick access for sequential and direct processing. • It reduces the degree of the sequential search.
  • 25. Disadvantages • Indexed sequential access file requires unique keys and periodic reorganization. • Indexed sequential access file takes longer time to search the index for the data access or retrieval. • It requires more storage space. • It is expensive because it requires special software. • It is less efficient in the use of storage space as compared to other file organizations.
  • 26. Partially-Indexed Sequential Files Key Record Address A 1 B 6 C 11 D 16 Record 1 2 3 4 5 6 7 8 9 10 11 12
  • 27. Fully Indexed Files • Every record has an index (address) • Sequentially search through key field for specific record address • Records may be accessed directly OR in sequential order by address
  • 28. Fully Indexed Files Key Record Address a 4 b 7 c 5 d 3 e 12 m 9 n 10 p 2 s 11 t 6 z 1
  • 29. Applications • ISAM (Indexed Sequential Access Method) is a file management system developed at IBM that allows  records to be accessed either sequentially (in the order they were entered) or randomly (with an index). Each index defines a different ordering of the records. An employee database may have several indexes, based on the information being sought. For example, a name index may order employees alphabetically by last name, while a department index may order employees by their department. A key is specified in each index. For an alphabetical index of employee names, the last name field would be the key.
  • 30. Application • Indexed sequential files are used when it is necessary to use both indexed and sequential access. A company might store an employee file as an indexed sequential file, because... • Sometimes only one record needs to be accessed ... ... an employee changes their address... ... use indexed access. • Sometimes all records need to be accessed... ... the end-of-month payroll is run... ... use sequential access.
  • 31. Comparison Sequential File Index File Relative/Random File Data is entered in entry sequential order Data is entered in key sequential order Data is entered in RRN number Duplicate data is allowed Duplicate data is not allowed Duplicate data is notallowed Data is in sorted order Data is in sorted order based on key Data is in sorted order based on RRN Delete is not applicable Delete is applicable Delete is applicable Access is slow Access is faster Access is faster than index files Key not available Key is available. Key is user defined. It is a part of record. Key is available. Key is system defined. It is outside of record. Data is stored on tape/Disk Data is stored on disk only Data is stored on disk only Frequently used Rarely used Not yet all used