INTRODUCTION TO FILE PROCESSING ,
DATA HIERARCHY
&
FILES AND STREAMS.
•INTRODUCTION.
>>File processing refers to the way data is stored,
retrieved, and manipulated within files.
>>Files store various documents and are grouped based on
categories.
>>Files names are related and arranged in a certain way
for easy access.
>>Data can be stored in tabular format and many other
formats using spaces or other separators.
>>In data structures, file processing involves managing and
manipulating data stored in files. It includes,opening,
reading data from files, writing data to files, updating
existing data in files, and deleting data from files.
C PROGRAM
1-Opening a file. 2-writing operation
3-Reading Operation. 4Closing a file
C PROGRAM ELEMENT MEANINGS.
•Char- character in a file
•EOF -when end of file is reached.
•getc- read character in a file
•putc - write a character in a file
•fopen- Opening a file
•fclose- closing a file.
•ADVANTAGES OF FILE PROCESSING:
Cost-Effective: File processing is an economical approach for
batch data processing. It’s scalable and suitable for various
types of organizations.
Easy to Use: File processing involves storing data in files,
which can be organized into usable documents. It’s
straightforward and often relies on string variables and file
names.
Scalable: File processing systems can handle a large number
of files on a single server without compromising
performance. Scalability is crucial for infrastructure growth.
Secure: Secure file processing ensures that untrusted clients
can process files within their sandbox, maintaining data
isolation and security.
•DISADVANTAGES OF FILE PROCESSING;
Data Redundancy: Duplicate data across files wastes storage
space and increases the risk of errors.
Data Inconsistency: Different files may contain conflicting
information, leading to inconsistencies.
Difficulty in Accessing Data: Sharing data between files can
be complex and requires programming expertise.
Data Isolation: Each department’s files may not relate to
others, hindering cross-departmental data access.
Data Security: Ensuring secure file access and preventing
unauthorized modifications can be challenging.
•HIERARCHY DATA.
>>is a data structure when items are linked to each other in
parent-child relationships in an overall tree structure. Think
of data like a family tree, with grandparents, parents,
children, and grandchildren forming a hierarchy of
connected data. Typically, this is used to show an
organizational chart, a project with tasks, or a taxonomy of
language.
>>Data hierarchies are useful when you have a large amount
of data that needs to be organized and classified in a logical
and efficient way. They can help to improve data
management, analysis, and decision-making by providing a
clear structure for understanding relationships between data
elements.
•ADVANTAGES OF DATA HIEARCHY
Simple Design: Hierarchical databases have a straightforward
structure. They organize data in a tree-like format, making it
easy to comprehend and manage.
Well-Structured Data Storage: With hierarchical databases,
you can customize the hierarchy to suit your needs. This
allows efficient organization of data into parent-child
relationships
Efficient Data Retrieval: Retrieving information from a
hierarchical database involves tracing a path up the tree
branches until you reach the desired record. This process is
intuitive and efficient1.
Facilitates One-to-Many Relationships: The model ensures a
consistent “one-to-many” linkage between records. Each child
node can be traced back to a distinct parent, maintaining data
integrity.
•DISADVANTAGES OF DATA HIEARCHY.
Limited Flexibility: Hierarchical databases are not as flexible as
other types of databases. They struggle with handling complex
data relationships or adapting to changes in data structures
Difficult Management of Large Data: Handling a large amount
of data in a hierarchical model can be challenging. Organizing
and retrieving data efficiently becomes tougher as the dataset
grows.
Complex Queries: Hierarchical databases have a limited scope
for queries. They primarily allow simple queries, making it
harder to perform complex data operations.
Impact of Structural Changes: When you modify the data
structure (e.g., adding or deleting segments), it can impact the
entire database. Deletion of one segment may inadvertently
delete all segments under it.
EXAMPLE SHOW DATA STRUCTURE HIERARCHY.
•FILES AND STREAMS
>>File is like a container that stores data on a more
permanent basis. On the other hand, a stream is like a
channel through which data flows, allowing you to read from
or write to files in a more dynamic and sequential manner.
>>Think of a file as a storage unit and a stream as a way to
interact with the data inside that storage unit. Files are
where the data is stored, while streams help you access and
manipulate that data effectively.
•FILE;
Definition:Files are persistent data storage units that store
information on storage media.They can represent various
types of data, such as text,image,binary etc
Types: Files can be regular files, directories, device files.
Advantages:
>>Persistence: Files retain data even after the program exits.
>>Structured Storage: Files organize data hierarchically (e.g.,
directories and subdirectories).
Disadvantages:
>>Slower I/O: File I/O can be slower due to disk access.
>>Limited Metadata: Files may lack rich metadata beyond
their name and location.
•STREAMS;
Definition: Streams are a higher-level abstraction for I/O
operations in programming languages.
Characteristics:
Generic Interface: Streams provide a generic interface for
reading from and writing to data sources (e.g., files, network
sockets).
Buffering: Streams often use buffering to improve
performance.(buffering-is the practice of pre loading and
storing a portion of media file in the "buffer"Also known as
temporary memory of a device.
Types: Standard input/output streams (stdin, stdout), file
streams, network streams, etc.
Advantages:
Convenience: Streams simplify I/O operations.
Uniformity: Streams allow consistent I/O across different
data sources.
Functional Programming: Streams encourage functional
programming patterns.
Disadvantages:
Less Control: Streams abstract away low-level details,
limiting fine-grained control.
Performance Overhead: Stream operations may introduce
some overhead.
RELATIONSHIP BETWEEN FILE AND STREAMS;
A file can be opened as a stream, providing an I/O
interface.
Streams can represent connections to files, devices, or
other data sources.
THE END.......
GROUP MEMBERS
KWIGEMA JOB JOSEPHINE 220323437366
MAJALIWA RAMADHANI BUZARAGI 220323308631
LATIFA MASOUD YUSUPH 220323456630
KELVIN MASENGO 220323445781
PETROSEMU MSHANA 220323448595