Dbms Assignment 5
Dbms Assignment 5
(a) A hash index organizes the search keys, with their associated 6 1 1.7.1 CO6
pointers into a hash file structure.
(c) Normalization is the process of removing anomalies from database 5 1 1.7.1 CO5
design.
Q4. Name or define or design the following.
(a) Functional dependency 5 1 1.7.1 CO5
(a) List all FDs satisfied by the following table T. 5 3 1.7.1 CO5
A B C D
A1 B1 C1 D1
A1 B1 C2 D2
A1 B2 C2 D1
A1 B2 C4 D4
(b) What are the different guidelines for designing relational schema? 5 4 1.7.1 CO5
(c) Explain 1NF, 2NF, 3NF and BCNF with example. 5 2 1.7.1 CO5
(a) When is it preferable to use a dense index rather than a sparse 6 4 2.5.1 CO5
index? Explain your answer.
(b) Since indices speed query processing, why might they not be kept 6 4 2.5.1 CO5
on several search keys? List as many reasons as possible.
Q8. My Ideas. (200 words)
(a) How insertion anomaly occurs if the table is not normalized? 5 4 2.5.1 CO5
(b) How updation anomaly occurs if the table is not normalized? 5 4 1.7.1 CO5
Q. Question
No
Q1. Fill in the blanks.
(a) If every non key attribute is functionally dependent on the primary key, then the relation will be in
Second Normal Form
(b) If the index is created on the basis of the primary key of the table, then it is known as
Primary indexing.
(c) Indexing based on a sorted order of values are called Ordered indices.
(d) While insertion in a sparse index, we assume that index stores an entry for each search key value.
(e) Indices having two or more levels are called multilevel indices.
(c) Normalization is the process of removing anomalies from database design. true
Q4. Name or define or design the following.
(a) Functional dependency
A functional dependency (FD) is a relationship between two attributes, typically between the PK
and other non-key attributes within a table. For any relation R, attribute Y is functionally dependent
on attribute X (usually the PK), if for every valid instance of X, that value of X uniquely determines
the value of Y.
(b) Normalization
Normalization is a database design technique which organizes tables in a manner that reduces
redundancy and dependency of data. It divides larger tables to smaller tables and links them using
relationships.
(c) Static hashing
In static hashing, when a search-key value is provided, the hash function always computes the same
address. For example, if mod-4 hash function is used, then it shall generate only 5 values.
Q5. Answer the following questions in brief. (20 to 30 words)
(a) List all FDs satisfied by the following table T.
A B C D
A1 B1 C1 D1
A1 B1 C2 D2
A1 B2 C2 D1
A1 B2 C4 D4
B C, D A, B A, C A
(b) What are the different guidelines for designing relational schema?
Guideline 1
Do not combine attributes from multiple entity types and relationship types into a single relation.
Guideline 2
Design the base relation schemas so that no insertion, deletion, or modification anomalies are present
in the relations.
Guideline 3
As far as possible, avoid placing attributes in a base relation whose values may frequently be NULL.
If NULLs are unavoidable, make sure that they apply in exceptional cases only and do not apply to a
majority of tuples in the relation.
Guideline 4
Design relation schemas so that they can be joined with equality conditions on attributes that are
appropriately related (primary key, foreign key) pairs in a way that guarantees that no spurious tuples
are generated. Avoid relations that contain matching attributes that are not (foreign key, primary key)
combinations because joining on such attributes may produce spurious tuples.
(c) Explain 1NF, 2NF, 3NF and BCNF with example. Normalize upto 3NF. A and B are the primary
keys.
Before we learn about the second normal form, we need to understand the following −
Prime attribute − An attribute, which is a part of the candidate-key, is known as a prime
attribute.
Non-prime attribute − An attribute, which is not a part of the prime-key, is said to be a
non-prime attribute.
If we follow second normal form, then every non-prime attribute should be fully functionally
dependent on prime key attribute. That is, if X → A holds, then there should not be any proper subset
Y of X, for which Y → A also holds true.
We see here in Student_Project relation that the prime key attributes are Stu_ID and Proj_ID.
According to the rule, non-key attributes, i.e. Stu_Name and Proj_Name must be dependent upon
both and not on any of the prime key attribute individually. But we find that Stu_Name can be
identified by Stu_ID and Proj_Name can be identified by Proj_ID independently. This is
called partial dependency, which is not allowed in Second Normal Form.
We broke the relation in two as depicted in the above picture. So there exists no partial dependency.
3.Third Normal Form
For a relation to be in Third Normal Form, it must be in Second Normal form and the following must
satisfy −
We find that in the above Student_detail relation, Stu_ID is the key and only prime key attribute. We
find that City can be identified by Stu_ID as well as Zip itself. Neither Zip is a superkey nor is City a
prime attribute. Additionally, Stu_ID → Zip → City, so there exists transitive dependency.
To bring this relation into third normal form, we break the relation into two relations as follows −
4.Boyce-Codd Normal Form
Boyce-Codd Normal Form (BCNF) is an extension of Third Normal Form on strict terms. BCNF
states that −
File Operations
Operations on database files can be broadly classified into two categories −
Update Operations
Retrieval Operations
Update operations change the data values by insertion, deletion, or update. Retrieval operations, on
the other hand, do not alter the data but retrieve them after optional conditional filtering.
In both types of operations, selection plays a significant role. 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
o removes all the locks (if in shared mode),
o saves the data (if altered) to the secondary storage media, and
o releases all the buffers and file handlers associated with the file.
1. Open hashing
2. Close hashing.
1.Open Hashing
In Open hashing method, Instead of overwriting older one the next available data block is used to enter
the new record, This method is also known as linear probing.
For example, A2 is a new record which you wants to insert. The hash function generates address as
222. But it is already occupied by some other value. That's why the system looks for the next data
bucket 501 and assigns A2 to it.
2.Close Hashing
In the close hashing method, when buckets are full, a new bucket is allocated for the same hash and
result are linked after the previous one.
B.Dynamic Hashing
Dynamic hashing offers a mechanism in which data buckets are added and removed dynamically and
on demand. In this hashing, the hash function helps you to create a large number of values.
(c ) What are the different types of indexes?
Indexing can be of the following types −
Primary Index − Primary index is defined on an ordered data file. The data file is ordered on
a key field. The key field is generally the primary key of the relation.
Secondary Index − Secondary index may be generated from a field which is a candidate key
and has a unique value in every record, or a non-key with duplicate values.
Clustering Index − Clustering index is defined on an ordered data file. The data file is
ordered on a non-key field.
Ordered Indexing is of two types −
Dense Index
Sparse Index
Dense Index
In dense index, there is an index record for every search key value in the database. This makes
searching faster but requires more space to store index records itself. Index records contain search
key value and a pointer to the actual record on the disk.
Sparse Index
In sparse index, index records are not created for every search key. An index record here contains a
search key and an actual pointer to the data on the disk. To search a record, we first proceed by index
record and reach at the actual location of the data. If the data we are looking for is not where we
directly reach by following the index, then the system starts sequential search until the desired data is
found.
Multilevel Index
Index records comprise search-key values and data pointers. Multilevel index is stored on the disk
along with the actual database files. As the size of the database grows, so does the size of the indices.
There is an immense need to keep the index records in the main memory so as to speed up the search
operations. If single-level index is used, then a large size index cannot be kept in memory which
leads to multiple disk accesses.
Multi-level Index helps in breaking down the index into several smaller indices in order to make the
outermost level so small that it can be saved in a single disk block, which can easily be
accommodated anywhere in the main memory.
Modification anomalies: With redundant data, when we want to change the value of one columns of a
particular Dentist, for example the dentistName, we must update all the Dentist records that assigned
to the particular patient otherwise the database will become inconsistent. We also need to modify the
appointment schedules because different Dentist has different schedules.