DBMS Cie-2 Imp
DBMS Cie-2 Imp
Unit-3 SAQ
1. Define 1NF and 2NF.[unit-3]
Ans: 1NF (First Normal Form): First Normal Form (1NF) ensures that each column in a table contains only single,
indivisible values. It eliminates repeating groups and data duplication. Think of 1NF as making sure each cell
has a unique value and there are no redundant or repeated information.
2NF (Second Normal Form): Second Normal Form (2NF) goes beyond 1NF and focuses on functional
dependencies. It states that each non-key attribute should be dependent on the entire primary key, avoiding
partial dependencies. Imagine 2NF as organizing data in a way that every non-key attribute fully relies on the
entire primary key, ensuring proper relationships and avoiding inconsistencies.
2.Write a short note on Lossless Join Decomposition [unit-3]
Ans: Lossless join decomposition is a process of dividing a relation into smaller parts while preserving all the
original information. It ensures that when the divided parts are combined again, we can recreate the original
relation without any data loss.
To achieve lossless join decomposition:
1. The decomposition should follow 1NF, 2NF, 3NF, or BCNF.
2. Choose a common attribute for the decomposition that is a candidate key or a super key in either or both
of the divided parts.
3.Define MVD and JD [unit-3]
AnsMVD:
MVD stands for "Multivalued Dependency". It's a type of dependency that exists between two attributes in a database table,
where one attribute value corresponds to multiple values of another attribute.
JD:
JD stands for "Join Dependency". It's a type of dependency that exists between two tables in a database, where the values of
one table are dependent on the values of another table, typically through a join operation.
A validation-based protocol is a type of protocol used in database systems to ensure data consistency and
DBMS CIE-II Question Bank
integrity. It works by checking the validity of data before it's inserted, updated, or deleted from a database.
How it works:
1. The protocol checks the data against a set of predefined rules or constraints.
2. If the data is valid, it's accepted and the operation is completed.
3. If the data is invalid, the operation is rejected and an error message is generated.
A Storage Access Mechanism is a way for a computer to access and retrieve data from a storage device, such
as a hard drive or solid-state drive.
Types:
1. Sequential Access: Data is accessed in a linear sequence, one piece at a time. (e.g., tape drives)
2. Random Access: Data can be accessed directly, without having to read the entire sequence. (e.g., hard
drives, solid-state drives)
Records in a file are organized in a specific way to make it easy to store, retrieve, and manage data. There are
three main ways to organize records:
1. Sequential Organization: Records are stored one after the other, in a linear sequence.
2. Indexed Organization: Records are stored with an index, which is a table that points to the location of
each record.
3. Hashed Organization: Records are stored using a hash function, which maps each record to a specific
location.
DBMS CIE-II Question Bank
LAQ
1 Explain 1NF, 2NF and 3 NF with suitable example. And illustrate the problems with thesenormalizations[unit3]
DBMS CIE-II Question Bank
o In the second normal form, all non-key attributes are fully functional dependent on the primary attributes
Example: Let's assume, a school can store the data of teachers and the subjects they teach.
In a school, a teacher can teach more than one subject.
DBMS CIE-II Question Bank
From above table one teacher is handling one or more subjects so Teacher_ id+subject is can is primary key which we
can identify the rows uniquely.
Teacher_Id,Subjectteacher_age which is Functionally dependent
But if we know teacher id we can get age details
TEACHER_IDAGE here it is partially dependent is .Which is not allowed in 2NF
Also inorder to get teacher age details there is no need to depend on subject details.
According to 2NF Rules all non-prime attributes should depend on primary attributes but here age which is non-key
attribute not depending on primary attribute subject. It violates the 2NF Rules so we need to decompose this table.
DBMS CIE-II Question Bank
Below is a student table that has student id, student name, subject id, subject name, and address of the
student as its columns.
In the above student table, stu_id determines subid, and subid determines sub. Therefore, stu_id determines sub via
subid. This implies that the table possesses a transitive functional dependency, and it does not fulfill the third normal
form criteria.
Stu_id-Subid
Subidsub
Stu_idsub transitively dependent which is not allowed in 3NF
Now to change the table to the third normal form, you need to divide the table as shown below
DBMS CIE-II Question Bank
As you can see in both the tables, all the non-key attributes are now fully functional, dependent only on the primary
key. In the first table, columns name, subid, and addresses only depend on stu_id. In the second table, the sub only
depends on subid.
2 Given a Relation R=(A,B,C) and Functional Dependencies are F={ {A,B}→{C}, {C}→{A} }. Determine all
Candidate keys of R and the normal form of R with proper explanation.[UNIT-3]
Ans: Candidate Keys:
A candidate key is a minimal set of attributes that uniquely identifies a tuple in a relation.
From the given functional dependencies:
{A, B} → {C} : This implies that A and B together determine C.
{C} → {A} : This implies that C determines A.
From these dependencies, we can infer the following:
A and B together determine C, so {A, B} is a superkey.
C determines A, so C alone cannot be a key (because it doesn't determine B).
Since {A, B} is a superkey, and C determines A, we can conclude that {B, C} is also a superkey.
Now, let's find the minimal sets of attributes that uniquely identify a tuple:
{A, B} is a candidate key because it's a minimal set that determines C.
{B, C} is also a candidate key because it's a minimal set that determines A.
Therefore, the candidate keys of R are:{A, B} {B, C}
Normal Form:
To determine the normal form of R, we need to check if it satisfies the conditions for each normal form.
First Normal Form (1NF):
R is in 1NF because each tuple contains a single value for each attribute.
Second Normal Form (2NF):
R is in 2NF because there are no partial dependencies. The functional dependency {A, B} → {C} is a full functional
dependency, and {C} → {A} is a transitive dependency.
Third Normal Form (3NF):
R is in 3NF because there are no transitive dependencies. The functional dependency {C} → {A} is not a transitive
dependency because C is not a non-prime attribute (it's part of a candidate key).
DBMS CIE-II Question Bank
In the above table, EMPCODE and PROJECTID together form the primary key because using EMPCODE
and PROJECTID; you can determine all the table columns.
EMPCODE,PROJECTIDPROJECT LEADER
PROJECT LEADERPROJECT ID
As for every project only one project leader is there. So if we know the project leader name we can identify the
projectid.But project leader is not super key.we need to decompose the table
EMPCODE PROJECTID
01 A01
01 B01
02 C01
03 D01
4. Fourth Normal Form is less stronger in Fifth Normal form is more stronger than Fourth Normal Form.
comparison to Fifth Normal form.
5. If a relation is in Fourth Normal Form then it will If a relation is in Fifth Normal Form then it will less redundancy.
have more redundancy.
6. If a relation is in Fourth Normal Form then it If a relation is in Fifth Normal Form then it cannot be decomposed
may be decomposed further into sub-relations. further into sub-relations without any modification in meaning or
facts.
Ans: Two Phase Locking is a technique used to control concurrent access to shared resources in a
database management system. The basic idea behind 2PL is to ensure that a transaction can only
acquire locks on resources after it has released all of its existing locks. This prevents deadlocks,
which can occur when two or more transactions are waiting for each other to release a lock.
Every transaction will lock and unlock the data item in two different phases.
Growing Phase − All the locks are issued in this phase. No locks are released, after all
changes to data-items are committed and then the second phase (shrinking phase) starts.
Shrinking phase − No locks are issued in this phase, all the changes to data-items are
noted (stored) and then locks are released.
In the growing phase transaction reaches a point where all the locks it may need has been
acquired. This point is called LOCK POINT.
After the lock point has been reached, the transaction enters a shrinking phase.
Types
Two phase locking is of two types
Cascading schedule: In this schedule one transaction is dependent on another transaction. So if one
has to rollback then the other has to rollback.
DBMS CIE-II Question Bank
The 2PL protocol guarantees serializability, but cannot guarantee that deadlock will not happen.
Example
Let T1 and T2 are two transactions.
Here,
In the above situation T1 waits for B and T2 waits for A. The waiting time never ends. Both the
transaction cannot proceed further at least any one releases the lock voluntarily. This situation is
called deadlock.
5 Define Serializability. Explain in detail about the types and Illustrate with the help of suitable example.[unit-4]
Ans: serializability ensures that the outcome of a set of concurrent transactions is the same as if they were executed
one after the other, in some order. This means that the database remains in a consistent state, even when multiple
transactions are accessing and modifying the data simultaneously.
Types of Serializability
1. Conflict Serializability
2. View Serializability
3. Causal Serializability
. Conflict Serializability:
Conflict serializability ensures that the order of conflicting operations (read-write, write-read, or write-write) is
preserved. Two operations conflict if they access the same data item and at least one of them is a write
operation.
Example
Three transactions—t1, t2, and t3—are active on a schedule “S” at once. Let’s create a graph of precedence.
DBMS CIE-II Question Bank
As there is no incoming edge on Transaction 1, Transaction 1 will be executed first. T3 will run second because it only
depends on T1. Due to its dependence on both T1 and T3, t2 will finally be executed.
Therefore, the serial schedule’s equivalent order is: t1 –> t3 –> t2
2. View Serializability:
View serializability ensures that the outcome of a set of transactions is equivalent to a serial execution,
considering the entire history of transactions.
Example
We have a schedule “S” with two concurrently running transactions, “t1” and “t2.”
Schedule – S:
DBMS CIE-II Question Bank
Schedule – S’:
DBMS CIE-II Question Bank
o The Multiple Granularity protocol enhances concurrency and reduces lock overhead.
o It makes easy to decide either to lock a data item or to unlock a data item. This type of hierarchy can be graphically
represented as a tree.
o The second level represents a node of type area. The higher level database consists of exactly these areas.
o The area consists of children nodes which are known as files. No file can be present in more than one area.
o Finally, each file contains child nodes known as records. The file has exactly those records that are its child nodes. No
records represent in more than one file.
o Hence, the levels of the tree starting from the top level are as follows:
1. Database
2. Area
3. File
4. Record
A deadlock occurs when two or more transactions are blocked, waiting for each other to release resources,
resulting in a never-ending cycle. Deadlock handling mechanisms aim to prevent or resolve deadlocks.
Deadlock Prevention:
Deadlock prevention protocols aim to eliminate one or more of the necessary conditions for deadlock
to occur. By avoiding the occurrence of these conditions, deadlocks can be prevented altogether.
Some popular deadlock prevention techniques include resource allocation ordering, where resources
are allocated in a predefined order, and deadlock avoidance, where the system checks for safe states
before granting resource requests.
2. Deadlock Avoidance:
Deadlock avoidance protocols dynamically analyze the resource allocation requests and make
decisions to avoid potential deadlocks.
These protocols employ algorithms that determine whether granting a resource request would result
in a safe state or lead to a potential deadlock. If the state is deemed safe, the resource is allocated;
otherwise, the request is delayed until a safe state can be guaranteed.
3. Deadlock Detection:
Deadlock detection protocols periodically examine the resource allocation state and check for the presence of deadlocks.
Common deadlock detection algorithms include the Wait-for Graph algorithm and the Banker's
algorithm. These algorithms analyze the resource allocation and request information to identify
circular wait or dependency chains that indicate the presence of a deadlock.
4. Deadlock Recovery:
Deadlock recovery protocols focus on recovering from a detected deadlock by taking corrective
actions.
Recovery actions may involve aborting one or more transactions involved in the deadlock, rolling back
their operations, or forcing the release of resources held by the deadlocked transactions.
Once the resources are released, the affected transactions can be restarted to continue their
execution.
7 What is Data storage? Explain Magnetic Disk and its types [unit-5]
Ans: Data storage in DBMS refers to the process of storing data in a database management system. Data in a
DBMS is stored on storage devices such as disks, magnetic disk and tapes. The disk space manager is
responsible for keeping track of available disk space. The file manager provides the abstraction of a file of
records to higher levels of DBMS code, issues requests to the disk space manager to obtain and relinquish
space on disk.
Magnetic disks are circular plates that are coated on both sides with a thin film of magnetic material. This
material has the property that it can store either ‘1’ or ‘0’ permanently. The magnetic material has square
loop hysteresis (curve) which can remain in one out of two possible directions which correspond to binary ‘1’
or ‘0’. Bits are saved in the magnetized surface in marks along concentric circles known as tracks. The tracks
are frequently divided into areas known as sectors. . The subdivision of one disk surface into tracks and
sectors is displayed in the figure.
DBMS CIE-II Question Bank
directly access slot 7 in the hash table and retrieve the student record.
DBMS CIE-II Question Bank
9
Explain different types of indexing with the help of suitable examples[unit-5]
Ans: different Types of indexing are:
1. Ordered Index.
2. Primary Index.
3. Clustering Index.
4. Sparse Index.
1. Ordered index: The indices are usually sorted to make searching faster. The indices which are sorted are
known as ordered indices.
Example: Suppose we have an employee table with thousands of record and each of which is 10 bytes
long. If their IDs start with 1, 2, 3... and so on and we have to search student with ID-543.
In the case of a database with no index, we have to search the disk block from starting till it reaches
543. The DBMS will read the record after reading 543*10=5430 bytes.
In the case of an index, we will search using indexes and the DBMS will read the record after reading
542*2= 1084 bytes which are very less compared to the previous case.
2. Primary Index:
If the index is created on the basis of the primary key of the table, then it is known as primary
indexing. These primary keys are unique to each record and contain 1:1 relation between the records.
As primary keys are stored in sorted order, the performance of the searching operation is quite
efficient.
The primary index can be classified into two types: Dense index and Sparse index.
3. Clustering Index:
A clustered index can be defined as an ordered data file. Sometimes the index is created on nonprimary
key columns which may not be unique for each record.
In this case, to identify the record faster, we will group two or more columns to get the unique value
and create an index out of them. This method is called a clustering index.
The records which have similar characteristics are grouped, and indexes are created for these groups.
4. Sparse Index:
In the data file, index record appears only for a few items. Each item points to a block.
In this, instead of pointing to each record in the main table, the index points to the records in the main
table in a gap.
Differentiate B and B+ Indexing[unit-5]
10
Ans:
DBMS CIE-II Question Bank
Explain different types of file organizations with the operations performed on files[unit-5]
11
Ans: File Organization refers to the logical relationships among various records that constitute the file,
particularly with respect to the means of identification and access to any specific record. In simple terms,
Storing the files in certain order is called file Organization. File Structure refers to the format of the label
and data blocks and of any logical control record.
Different types of file organization:
1. Heap file organization: Any record can be placed anywhere in the file where there is space for the record.
There is no ordering of records.
2. Sequential file organization: Records are stored in sequential order, based on the value of the search key
of each record.
3. Hashing file organization: A hash function is computed on some attribute of each record. The result of
the function specifies in which block of the file the record should be placed.
4. Clustering file organization: Records of several different relations can be stored in the same file. Related
records of the different relations are stored on the same block so that one I/O operation fetches related
records from all the relations.
5. B+ Tree File Organization: B+ tree is a balanced tree structure that is used to store large amounts of data
in a sorted manner.
6. B-Tree File Organization: B-Tree file organization uses a balanced tree structure (typically a B-Tree or B+-
Tree) to store records. The tree structure allows for efficient searching, insertion, and deletion of records.
B-Trees are commonly used in indexing and provide good performance for a wide range of applications.
7. Indexed Sequential File Organization: Indexed sequential file organization combines the benefits of
sequential and indexed file organization. Records are stored in a sequential order, but an index structure
is created to allow efficient searching and retrieval of specific records. This method is suitable for
applications that require both sequential access and random access to records.
8. Partitioned File Organization: Partitioned file organization involves dividing a large file into smaller
partitions or segments. Each partition can be stored on a separate disk or storage device, enabling parallel
processing and improved performance for large databases. Partitioning can be done based on a range of
values or using hash functions.