Database Assignment
Database Assignment
ID_NO - RCD/0909/2014
SECTION-RCD2014E
o File organization is used to describe the way in which the records are
stored in terms of blocks, and the blocks are placed on the storage
medium.
o The first approach to map the database to the file is to use the several
files and store only one fixed length record in any given file. An
alternative approach is to structure our files so that we can contain
multiple lengths for records.
Operation on files
It allows you to automate file operations such as create, move, rename, zip and
others. A few of the operations such as open operation, are limited to specific file
types as the specific application would be required to open the file.
The application associated with the file type must be present in the system for
the automation process workflow to perform the required file operation. For
example, if you want to perform a file operation on an excel file, ensure that you
have MS Excel installed on the system.This activity can be used for files available
on the network drive as well.
Example:
Create=>It helps you to automate the creation of a new file and store it at a
specified location, with a desired extension such as .doc, .docx, .txt, .jpg, .html
and others.
Copy==>It helps you to automate copying of one or multiple files from one
location to another. You can use this operation to streamline high volume and
complex files to copy from one location to another more efficiently, accurately
and in less time.
Move==>It helps you to automate moving of one or multiple files from one
location to another. By automating the file transfer, you can prevent moving
sensitive data to unwanted location and avoid end point vulnerabilities. It helps
you to move multiple files with greater accuracy and in lesser time.
Save As==>It helps you to automate saving an open file with a desired name
and file extension. Automating the task of saving files prevents the possibility
of losing any unsaved data due to system failure or human error.
Zip==>It helps you to automatically zip one or more files inside a folder.
Automating the task of zipping files facilitates data organization and transfer
accurately and efficiently. It saves the administrative time and effort required to
manage multiple files transfer.
Convert==>It helps you to automatically convert one file type to another, thus
having all the conversions consistent every time. It allows you have ideal file
formats for security and shareability. It saves time and effort for ongoing,
constant file conversion requirements.
When the data block is full, the new record is stored in some other block. This
new data block need not to be the very next data block, but it can select any
data block in the memory to store new records. The heap file is also known as
an unordered file.
In the file, every record has a unique id, and every page in a file is of the
same size. It is the DBMS responsibility to store and manage the new
records.
If we want to search, update or delete the data in heap file organization, then
we need to traverse the data from staring of the file till we get the requested
record.
If the database is very large then searching, updating or deleting of record will
be time-consuming because there is no sorting or ordering of records. In the
heap file organization, we need to check all the data until we get the
requested record.
Pros of Heap file organization
o This method is inefficient for the large database because it takes time
to search or modify the record.
o This method is inefficient for large databases.
o In this method, the new record is always inserted at the file's end, and
then it will sort the sequence in ascending or descending order. Sorting
of records is based on any primary key or any other key.
o In the case of modification of any record, it will update the record and
then sort the file, and lastly, the updated record is placed in the right
place.
o It contains a fast and efficient method for the huge amount of data.
o In this method, files can be easily stored in cheaper storage mechanism
like magnetic tapes.
o It is simple in design. It requires no much effort to store the data.
o This method is used when most of the records have to be accessed like
grade calculation of a student, generating the salary slip, etc.
o This method is used for report generation or statistical calculations.
Hashing Techniques
#.In this technique, data is stored at the data blocks whose address is
generated by using the hashing function. The memory location where these
records are stored is known as data bucket or data blocks.
In this, a hash function can choose any of the column value to generate the
address. Most of the time, the hash function uses the primary key to generate
the address of the data block. A hash function is a simple mathematical
function to any complex mathematical function. We can even consider the
primary key itself as the address of the data block. That means each row
whose address will be the same as a primary key stored in the data block.
::The above diagram shows data block addresses same as primary key value.
This hash function can also be a simple mathematical function like
exponential, mod, cos, sin, etc. Suppose we have mod (5) hash function to
determine the address of the data block. In this case, it applies mod (5) hash
function on the primary keys and generates 3, 3, 1, 4 and 2 respectively, and
records are stored in those data block addresses.
Types of Hashing
1.Static Hashing==>In static hashing, the resultant data bucket address will
always be the same. That means if we generate an address for EMP_ID =103
using the hash function mod (5) then it will always result in same bucket
address 3. Here, there will be no change in the bucket address.
Hence in this static hashing, the number of data buckets in memory remains
constant throughout. In this example, we will have five data buckets in the
memory used to store the data.
If we want to insert some new record into the file but the address of a data
bucket generated by the hash function is not empty, or data already exists in
that address. This situation in the static hashing is known as bucket overflow.
This is a critical situation in this method.
To overcome this situation, there are various methods. Some commonly used
methods are as follows:
1. Open Hashing
When a hash function generates an address at which data is already stored,
then the next bucket will be allocated to it. This mechanism is called as Linear
Probing.
2. Close Hashing
When buckets are full, then a new data bucket is allocated for the same hash
result and is linked after the previous one. This mechanism is known
as Overflow chaining.
Dynamic Hashing
o The dynamic hashing method is used to overcome the problems of
static hashing like bucket overflow.
o In this method, data buckets grow or shrink as the records increases or
decreases. This method is also known as Extendable hashing method.
o This method makes hashing dynamic, i.e., it allows insertion or deletion
without resulting in poor performance.