Clustered file organization
-> When the two or more records are stored in the same file, it is known as clusters. These files will have two or more tables in the same data block, and key attributes which are used to map these tables together are stored only once.
-> This method reduces the cost of searching for various records in different files.
-> The cluster file organization is used when there is a frequent need for joining the tables with the same condition.In the given example, we are retrieving the record for only particular departments. This method can't be used to retrieve the record for the entire department.
-> In this method, we can directly insert, update or delete any record. Data is sorted based on the key with which searching is done. Cluster key is a type of key with which joining of the table is performed.
Types of Cluster file organization:
Cluster file organization is of two types:
1. Indexed Clusters:-
In indexed cluster, records are grouped based on the cluster key and stored together. The above EMPLOYEE and DEPARTMENT relationship is an example of an indexed cluster. Here, all the records are grouped based on the cluster key- DEP_ID and all the records are grouped.
2. Hash Clusters:-
It is similar to the indexed cluster. In hash cluster, instead of storing the records based on the cluster key, we generate the value of the hash key for the cluster key and store the records with the same hash key value.
Pros of Cluster file organization -
1. The cluster file organization is used when there is a frequent request for joining the tables with same joining condition.
2. It provides the efficient result when there is a 1:M mapping between the tables.
Cons of Cluster file organization -
1. This method has the low performance for the very large database.
2. This method is not suitable for a table with a 1:1 condition.
-> When the two or more records are stored in the same file, it is known as clusters. These files will have two or more tables in the same data block, and key attributes which are used to map these tables together are stored only once.
-> This method reduces the cost of searching for various records in different files.
-> The cluster file organization is used when there is a frequent need for joining the tables with the same condition.In the given example, we are retrieving the record for only particular departments. This method can't be used to retrieve the record for the entire department.
-> In this method, we can directly insert, update or delete any record. Data is sorted based on the key with which searching is done. Cluster key is a type of key with which joining of the table is performed.
Types of Cluster file organization:
Cluster file organization is of two types:
1. Indexed Clusters:-
In indexed cluster, records are grouped based on the cluster key and stored together. The above EMPLOYEE and DEPARTMENT relationship is an example of an indexed cluster. Here, all the records are grouped based on the cluster key- DEP_ID and all the records are grouped.
2. Hash Clusters:-
It is similar to the indexed cluster. In hash cluster, instead of storing the records based on the cluster key, we generate the value of the hash key for the cluster key and store the records with the same hash key value.
Pros of Cluster file organization -
1. The cluster file organization is used when there is a frequent request for joining the tables with same joining condition.
2. It provides the efficient result when there is a 1:M mapping between the tables.
Cons of Cluster file organization -
1. This method has the low performance for the very large database.
2. This method is not suitable for a table with a 1:1 condition.