Database Management System
Entity Relationship Model
Transaction And Concurrency Control
Files and Storage
What is a file? Explain it's uses.
A file is an object on a computer that stores data, information, settings, or commands used with a computer program.
Multimedia files which are videos,audios which helps to entertain us.
Archive files can be used for compressed foders and backups.
System files - these are files which we don’t use but they must be on our computer for it to function well
Document files helps to store text data.
Define File Organization.
The Term “file Organization” refers to the way in which data is stored in a file and, consequently the methods by which it can be accessed.Storing the file in a certain order and approach to by which we can access this data.Records can be placed anywhere in the file or record may be stored in an ordered way.
What are the different types of File Organization?
Some of the type of file organization are
1. Sequential File Organization:
In sequential file organization file is stored as they come or sorted as they come Fast and efficient when there is large volumes of data, Report generation, statistical calculations etc.Storage cost is Cheap (magnetic tapes).It has Simple Design.Sorting of data each time for insert/delete/ update takes time and makes system slow.
2. Heap File Organization:
In heap file organization Stored at the end of the file. But the address in the memory is random. It has Simplest Design. Storage cost is Cheap. Best suited for bulk insertion, and small files/tables. Records are scattered in the memory and they are inefficiently used. Hence increases the memory size.Proper memory management is needed.Not suitable for large tables.
3. Hash/Direct File Organization:
In hash Stored at the hash address generated. It has moderate Design. Storage cost is moderate.Faster Access No Need to Sort Handles multiple transactions Suitable for Online transactions. Accidental Deletion or updation of Data Use of Memory is inefficient.Searching range of data, partial data, non-hash key column, searching single hash column when multiple hash keys present or frequently updated column as hash key are inefficient.
4. Indexed Sequential Access Method:
In Indexed Sequential Access Method Address index is appended to the record. It has complex Design. Storage cost is Costly. Searching records is faster. Suitable for large database.Any of the columns can be used as key column.Searching range of data & partial data are efficient. Extra cost to maintain index.File reconstruction is needed as insert/update/delete. Does not grow with data.
5. B+ Tree File Organization:
It is Stored in a tree like structure. It has complex Design. Storage cost is costly. Searching range of data & partial data are efficient.No performance degrades when there is insert / delete / update.Grows and shrinks with data.Works well in secondary storage devices and hence reducing disk I/O.Since all datas are at the leaf node, searching is easy.All data at leaf node are sorted sequential linked list Not suitable for static tables
6. Cluster File Organization:
In cluster file organization Frequently joined tables are clubbed into one file based on cluster key. It has Simple Design. Storage cost is moderate. Best suited for frequently joined tables.Suitable for 1:M mappings. Not suitable for large database.Suitable only for the joins on which clustering is done. Less frequently used joins and 1: 1 Mapping are ine
What are the different operations that can be performed on files?
Other than creation and deletion of a file, there could be several operations, which can be done on files.
Open − A file can be opened in one of the two modes, read mode or write mode. In read mode, the operating system does not allow anyone to alter data. In other words, data is read only. Files opened in read mode can be shared among several entities. Write mode allows data modification. Files opened in write mode can be read but cannot be shared.
Locate − Every file has a file pointer, which tells the current position where the data is to be read or written. This pointer can be adjusted accordingly. Using find (seek) operation, it can be moved forward or backward.
Read − By default, when files are opened in read mode, the file pointer points to the beginning of the file. There are options where the user can tell the operating system where to locate the file pointer at the time of opening a file. The very next data to the file pointer is read.
Write − User can select to open a file in write mode, which enables them to edit its contents. It can be deletion, insertion, or modification. The file pointer can be located at the time of opening or can be dynamically changed if the operating system allows to do so.
Close − This is the most important operation from the operating system’s point of view. When a request to close a file is generated, the operating system
1. removes all the locks (if in shared mode),
2. saves the data (if altered) to the secondary storage media, and
3. releases all the buffers and file handlers associated with the file.