Unit v Dbms Question and Answer
Unit v Dbms Question and Answer
What is a File?
A file is named a collection of related information that is recorded on secondary storage such as magnetic disks, magnetic
tapes, and optical disks.
The index size is larger in dense index. In sparse index, the index size is smaller.
Time to locate data in index table is less. Time to locate data in index table is more.
There is more overhead for insertions and Sparse indexing have less overhead for
deletions in dense index. insertions and deletions.
Records in dense index need not to be In case of sparse index, records need to be
clustered. clustered.
Computing time in RAM (Random access In sparse index, computing time in RAM is
memory) is less with dense index. more.
Data pointers in dense index point to each In sparse index, data pointers point to
record in the data file. fewer records in data file.
Dense index Sparse index
DENSE INDEX
SPARSE INDEX
Q3 EXPLAIN FILE OF ORDERED RECORDS AND UNORDERED RECORDS .
FILE OF ORDERED RECORDS
1 ALSO CALLED AS SEQUENTIAL FILE
2 RECORDS ARE SORTED BY VALUES OF ORDERING FIELD
3 INSERTION OF NEW RECORD IS EXPENSIVE ,RECORDS MUST BE INSERTED IN CORRECT ORDER.
4 BINARY SEARCH CAN BE USED TO SEARCH FOR RECORD ON ITS ORDERING FIELD VALUE .
5 READING RECORDS IN ORDER OF ORDERING FIELD IS EFFICIENT
6 EASIER TO SEARCH .
7 Insertion and deletion of records is slower in ordered files
8 Ordered files have a specific order
9 Insertion and deletion: Insertion and deletion of records is slower in ordered files
FILE OF UNORDERED RECORDS
1 RECORDS ARE PLACED IN FILE IN ORDER IN WHICH THEY ARRIVE .
2 LINEAR SEARCH IS USED TO SEARCH RECORDS .
3 HEAP FILE FOLLOWS THIS CONCEPT.
4 UNORDERED FILES CAN BE ACCESSED IN ANY ORDER.
5 TOUGH TO SEARCH
6 Insertion and deletion of records is FAST in ordered files
7 UN Ordered files DO NOT have a specific order
8 Insertion and deletion: Insertion and deletion of records is FAST in ordered files
Q4 EXPLAIN FILE OPERATIONS .
Open − A file can be opened in one of the two modes, read mode or write mode.
Locate − Every file has a file pointer, which tells the current position where the data is to be
read or written.
Read − By default, when files are opened in read mode, the file pointer points to the
beginning of the file.
Write − User can select to open a file in write mode, which enables them to edit its
contents.
Close - CLOSE THE FILE
Indexed file organization is a method of storing records in a computer file using a record key
to uniquely identify each record. The record key is a field within each record that determines
the order in which the records are accessed
characteristics of indexed file organization
• Record keys: Each record has a unique record key, such as an employee number or
invoice number.
• Indexes: Each key is associated with an index that provides a logical path to the record.
• Access modes: Indexed files can be accessed sequentially, randomly, or dynamically