Professional Documents
Culture Documents
Cust ID Cust Name Cust City
Cust ID Cust Name Cust City
Cust ID Cust Name Cust City
Q.1 Explain the functions and advantages of a DBMS over a traditional file system.
Q. 2 Describe indexing and clustering techniques with relevant real time examples.
Ans : Clustering – If the page containing the requested record is already in the memory, retrieval from the disk is not
necessary. In such a situation, time taken for the whole operation will be less.Thus, if records which are frequently used
together are placed physically together, more records will be in the same page. Hence the number of pages to be retrieved
will be less and this reduces the number of disk accesses which kin turn gives a better performance.
This method of storing logically related records, physically together is called clustering.
Example - Consider CUSTOMER table as shown below.
If queries retrieving Customers with consecutive Cust_IDs frequently occur in the application, clustering based on Cust_ID
will help improving the performance of these queries. This can be explained as follows.
Assume that the Customer record size is 128 bytes and the typical size of a page retrieved by the File Manager is 1 kb (1024
bytes).
If there is no clustering, it can be assumed that the Customer records are stored at random physical locations. In the worst-
case scenario, each record may be placed in a different page. Hence a query to retrieve 100 records with consecutive
Cust_Ids (say ,10001 to 10100), will require 100 pages to be accessed which in turn translated to 100 disk accesses.
Indexing – Indexing is another common method for making retrievals faster.
Consider the example of CUSTOMER table used above. The following query is based on Customer’s City.
Here a sequential search on the CUSTOMER table has to be carried out and all records with the value ‘Delhi’ in the
Cust_City field have to be retrieved. The time taken for this operation depends on the number of pages to be accessed. If the
records are randomly stored, the page accesses depends on the volume of data. If the records are randomly stored, the page
accesses depends on the volume of data. If the records are stored physically together, the number of pages depends on the
size of each record also.
If such queries based on Cust_City field are very frequent in the application, steps can be taken to improve the performance
of these queries. Creating an Index on Cust_City is one such method. This results in the scenario as shown below.
Indexing
City(Index)
City CustN Name City
Mumbai o
Mumbai Q.3 Describe various 001 Shah Mumbai integrity rules with a
Kolkata relevant example. 002 Srinivasa Chennai
Delhi n
Ans : Integrity Rules 003 Gupta Delhi – The following are the
Chennai
integrity rules to be satisfied 004 Banerjee Kolkata by any relation.
No Component of the 005 Apte Mumbai Primary Key can be null.
006 Krishnan Chennai
The Database must not contain any unmatched Foreign Key values. This
is called the referential integrity rule.
Unlike the case of Primary keys , there is no integrity rule saying that no component of the foreign key can be null. This can
be logically explained with the help of the following example:
Consider the relations Employee and account as given below:
Employee
Emp# EmpName EmpCity EmpAcc#
X101 Manzar Siliguri 120001
X102 Shanawaj Mumbai 120002
X103 Ranjana Delhi Null
X104 Begum Pune 120003
Account
Acc# OpenDate BalAmt
120001 30-08-98 500
120002 29-10-98 1200
120003 01-01-99 3000
120004 04-03-99 500
EmpAcc# in Employee relation is a foreign key creating reference from Employee to Account. Here, a Null value in
EmpAcc# attribute is logically possible if an Employee does not have a bank account. If the business rules allow an
employee to exist in the system without opening an account, a Null value can be allowed for EmpAcc# in Employee relation.
In the case example given, Cust# in Ord_Aug cannot accept Null if the business rule insists that the Customer No. Needs to
be stored for every order placed.