0% found this document useful (0 votes)
28 views14 pages

Question Bank For II Mid Exams-Dbms

Uploaded by

darkendusk07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views14 pages

Question Bank For II Mid Exams-Dbms

Uploaded by

darkendusk07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

HYDERABAD INSTITUTE OF TECHNOLOGY & MANAGEMENT (AUTONOMOUS)

Gowdavelli, -Medchal Dist. – 501 401

CONTINUOUS INTERNAL EVALUATION MID-II Exam odd Semester :


II Yr. I Sem /
Faculty In-Charge : Branch:
Subject Name :DBMS Time : 1
Date : Hour
Subject Code :22PC3CS02
Bloom
Q. PART-A (1 Mark Question) Marks ’s COs Pos
No
Level

Module – III
1 Explain about functional dependency?

Functional Dependency is a relationship between two


sets of attributes in a relational database. It defines a
constraint between two attributes (or sets of attributes)
such that one attribute (or set) uniquely determines
another attribute (or set).
X → Y means that knowing the value of X allows you to
uniquely determine the value of Y.
Example:
Student_ID → Student_Name:
 If you know a student's ID, you can determine
their name. Here, Student_ID determines
Student_Name.
2 What is schema refinement?

Schema refinement is the process of improving a


database schema to eliminate redundancy,
inconsistencies, and anomalies while ensuring that the
schema is efficient and meets the desired data integrity
constraints. It is typically achieved through
normalization, which involves decomposing a complex
schema into simpler, more manageable sub-schemas.
3 Explain the problems due to redundancy?

Problems Due to Redundancy


1. Inconsistency: Conflicting data when updates aren't applied
uniformly.
2. Update Anomalies: Risk of missing updates in multiple places.
3. Insertion Anomalies: Inserting unnecessary data, like null values.
4. Deletion Anomalies: Losing important data during deletion.
5. Wasted Storage: Increased space usage due to repeated data.
6. Inefficient Queries: Slower queries due to unnecessary data
repetition.
4 What is Decomposition ?

Decomposition in databases refers to the process of breaking


down a complex relational schema into smaller, simpler sub-
schemas or tables. The goal is to remove redundancy, improve
data integrity, and eliminate anomalies without losing any
essential data.
Example:
Suppose a table with columns Student_ID, Student_Name,
Course_ID, and Instructor_Name can be decomposed into two
tables: one for Student-Course relationships and another for
Course-Instructor relationships to remove redundancy
5 Define Multi valued dependencies and join dependency?

Multi-Valued Dependency (MVD)


A Multi-Valued Dependency (MVD) occurs when one attribute
determines multiple independent attributes. It means for each value
of one attribute, there are multiple values of other attributes.
 Example: If Student_ID →→ Phone_Number and Student_ID
→→ Address, each student can have multiple phone numbers
and addresses, independent of each other.
Join Dependency (JD)
A Join Dependency (JD) occurs when a relation can be decomposed
into sub-relations, and the original relation can be reconstructed by
joining these sub-relations.
 Example: For a relation R(Student_ID, Course_ID,
Instructor_Name), decomposing it into R1(Student_ID,
Course_ID) and R2(Course_ID, Instructor_Name) allows
reconstruction of the original relation by joining on
Course_ID.
Module – IV
1 What is locking Protocol?

Locking Protocol
A locking protocol is a set of rules governing how transactions acquire
and release locks on data items to ensure serializability and prevent
conflicts in concurrent environments.
Purpose: To ensure data consistency and avoid conflicts in concurrent
transactions.

2 What is transaction? Explain the properties of transaction.

Transaction
A transaction is a sequence of database operations treated as a single
unit, ensuring consistency and integrity. Either all operations are
completed, or none are executed.
ACID Properties:
1. Atomicity: All operations in a transaction are executed or none at
all.
2. Consistency: The transaction ensures the database moves from
one valid state to another.
3. Isolation: Transactions are independent, with no interference
from others.
4. Durability: Once committed, changes are permanent, even in
case of a crash.
3 Write about Log based recovery?

Log-based recovery is a method used to ensure database consistency


and durability by maintaining a log of all transactions. The log records
every operation (such as insert, update, delete) along with their before
and after images, allowing the database to recover to a consistent state
after a crash.
4 Explain about Serializability?

Serializability:
Serializability ensures that the result of executing concurrent
transactions is the same as if they were executed serially.
Types:
1. Conflict Serializability: Transactions can be reordered
without conflicts.
2. View Serializability: Transactions produce the same result
as some serial execution.

5 Explain about Schedules?

Schedules:
A schedule is the order of operations from multiple transactions.
Types:
1. Valid Schedule: Follows consistency rules.
2. Conflict Serializable Schedule: Can be rearranged to a serial order
without conflicts.
3. Recoverable Schedule: Commits transactions only after all
dependencies are written.

Module – V
1 What is primary and secondary indexing?

1. Primary Indexing: Built on the primary key of a table,


organizing data in its order for efficient searching. Only one
per table.
2. Secondary Indexing: Created on non-primary key columns to
improve search performance. Multiple secondary indexes can
exist per table.
2 What are the features of B+ trees?

Features of B+ Trees
1. Balanced: All leaf nodes are at the same level.
2. Sorted Data: Enables efficient search and range queries.
3. Leaf Nodes Linked: Provides fast sequential access.
4. Internal Nodes Store Only Keys: Data is stored in leaf nodes.
5. Efficient Operations: Logarithmic time for search, insert, and
delete.
6. Supports Range Queries: Linked leaves allow fast range
queries.
7. High Fan-out: Reduces tree height and improves
performance.
3 Explain difference between indexing and hashing?
4 What is an index on a file of records? Why is it needed?

Index on a File of Records


An index is a data structure that maps a search key to the corresponding
record, improving data retrieval speed.

Why Needed:
 Faster Retrieval
 Efficient Queries
 Improved Performance
 Optimized Access
5 Define Types of Indexing

Types of Indexing
1. Single-Level Indexing: One index points directly to data records.
2. Multi-Level Indexing: Indexes point to other indexes, reducing access
time.
3. Clustered Indexing: Data is ordered by the index key.
4. Non-Clustered Indexing: Index is separate from data records.
5. B-Tree Indexing: Tree structure for efficient search, insert, and delete.
6. B+ Tree Indexing: B-Tree variant with linked leaves for faster range
queries.
7. Hashing: Index based on hash functions for exact match queries.

Bloom
Q. PO
PART-B ( 5 Mark Question) Marks ’s COs
No s
Level

Module – III

1 Explain 4NF, 5NF normal forms with examples?

4th Normal Form (4NF):


A table is in 4NF if:
1. It is in Boyce-Codd Normal Form (BCNF).
2. It has no multi-valued dependencies.

Example:
A table storing Course, Teacher, and Book where a course can have
multiple teachers and books:

This violates 4NF due to multi-valued dependencies:


 A Course determines multiple Teachers.
 A Course determines multiple Books.

Solution:
Split into two tables:
Courses-Teachers:

Courses-Books:
5th Normal Form (5NF):
A table is in 5NF if:
1. It is in 4NF.
2. It has no join dependency anomalies.

Example:
A table storing Project, Task, and Team Member:

The table depends on combinations of attributes, creating


redundancy.

Solution:
Split into three tables:
Projects-Tasks:

Tasks-Team Members:

Projects-Team Members:

These splits eliminate the dependency anomalies.


2 What are the conditions required for a relation to be in 1NF, 2NF?

1st Normal Form (1NF):


A relation is in 1NF if:
1. Atomic values: All attributes (columns) contain
only indivisible, atomic values.
2. No repeating groups: There are no sets, lists, or
arrays as column values.
3. Unique rows: Each row must have a unique
identifier (primary key).
Example:
Non-1NF table:

Converted to 1NF:
2nd Normal Form (2NF):
A relation is in 2NF if:
1. It is in 1NF.
2. There are no partial dependencies: No non-
prime attribute (non-key column) depends only on
part of a composite primary key.
Example:
Non-2NF table:

 Composite key: (StudentID, CourseID).


 Partial dependency: CourseName depends only
on CourseID.
Converted to 2NF:
Student-Course:

Course:

3 What are the steps to be followed to convert a relation in 3NF to BCNF?

To convert a relation from 3NF to Boyce-Codd Normal Form (BCNF),


follow these steps:

1. Check for BCNF Violation:


 A table is in BCNF if every functional dependency (FD) X → Y
satisfies:
o X (determinant) is a superkey.
 If a functional dependency exists where X is not a superkey, it
violates BCNF.
2. Identify the Problematic Functional Dependency:
 Find the functional dependency that causes the violation.
 Example: If FD: A → B and A is not a superkey, this FD violates
BCNF.
3. Decompose the Relation:
 Split the table into two relations:
1. One relation with the attributes of the violating FD (A
and B in this case).
2. Another relation with the remaining attributes and A as a
foreign key.
4. Repeat the Process:
 Check each resulting table for further BCNF violations.
 Continue decomposing until all tables are in BCNF.
Example:
Given Relation (3NF):

Functional Dependencies:
1. StudentID, CourseID → Instructor, Dept (Primary key).
2. Instructor → Dept (BCNF violation because Instructor is not a
superkey).
Steps to Convert to BCNF:
1. Decompose based on Instructor → Dept:
o Table 1: Instructor, Dept.
o Table 2: StudentID, CourseID, Instructor.
Resulting Tables in BCNF:

4 When is the decomposition of a relation schema R into two relation


schemas X and Y said to be lossless-join decomposition? Why is this
property so important? Give a necessary and sufficient condition to test
whether a decomposition is lossless-join.

Lossless-Join Decomposition
A decomposition of a relation schema R into two relation schemas
X and Y is lossless-join if the natural join of X and Y results in the
original relation R without any loss of information.

Why is Lossless-Join Important?


Lossless-join decomposition ensures that no spurious tuples are
introduced when the decomposed relations are joined back. This
property is critical to preserve the integrity and correctness of the
data. Without it, the decomposition could lead to incorrect or
incomplete results during queries.

Condition for Lossless-Join Decomposition


Necessary and Sufficient Condition:
A decomposition of R into X and Y is lossless-join if:
X∩Y→X or X∩Y→Y
This means the attributes common to X and Y (X∩Y) must be a
superkey in either X or Y.

Example of Lossless-Join:
Relation R:

Functional Dependencies:
1. StudentID,CourseID→Instructor
2. Instructor→Dept
Decomposition:
1. X={Instructor,Dept}
2. Y={StudentID,CourseID,Instructor}
Testing Lossless-Join:
 X∩Y={Instructor}
 Instructor→Dept(Instructor is a superkey in X).
Thus, the decomposition is lossless-join.
Example of Lossy Decomposition:
If X={StudentID,CourseID} and Y={Instructor,Dept}:
 X∩Y=∅.
 No superkey condition can be satisfied.
This decomposition is not lossless-join and would result in
spurious tuples.
5 Explain in detail about 1NF, 2NF and 3NF with suitable examples. Find
the highest normal form in R(A, B, C, D, E) under following functional
dependencies.
ABC -> D
CD -> AE

1st Normal Form (1NF):


A relation is in 1NF if:
1. All attributes contain atomic values (indivisible).
2. There are no repeating groups.

2nd Normal Form (2NF):


A relation is in 2NF if:
1. It is in 1NF.
2. No partial dependencies exist, i.e., no non-prime attribute is
dependent on only a part of a composite primary key.

3rd Normal Form (3NF):


A relation is in 3NF if:
1. It is in 2NF.
2. No transitive dependencies exist, i.e., no non-prime attribute
depends on another non-prime attribute.
Finding the Highest Normal Form for R(A,B,C,D,E)R(A, B, C, D,
E)R(A,B,C,D,E):
Functional Dependencies (FDs):
1. ABC→D
2. CD→A
Step 1: Check 1NF:
 Assume all attributes have atomic values, so R is in 1NF.
Step 2: Check 2NF:
 Candidate keys:
o ABC(from FD ABC→D, and using CD→AE).
 Partial dependencies: None, since all non-prime attributes (D,A,E)
depend on the full candidate key ABC.
 R is in 2NF.
Step 3: Check 3NF:
 Analyse transitive dependencies:
o From CD→AE, A and E depend on CD. However, CD is not a
non-prime attribute (it is part of a superkey).
 No transitive dependencies exist.
 R is in 3NF.
Step 4: Check BCNF:
 ABC→D: ABC is a superkey.
 CD→AE: CD is not a superkey, which violates BCNF.
Conclusion:
 The highest normal form of R(A,B,C,D,E) is 3NF.

Module – IV

1 Explain the Time Stamp - Based Concurrency Control protocol. How is it


used to ensure serializability?

Timestamp-Based Concurrency Control Protocol

The Timestamp-Based Concurrency Control protocol is a method used


in database systems to ensure serializability by assigning a unique
timestamp to each transaction. The timestamps help in ordering the
operations of different transactions, ensuring that the final result is
serializable.
How It Works:
1. Timestamp Assignment:
o Each transaction is assigned a unique timestamp when it
starts. The timestamp is used to order transactions,
ensuring that the transaction with the earlier timestamp
is considered to come first.
2. Operation Rules:
o Read Rule: A transaction Tj can read a data item X only if
the timestamp of Tj is greater than the write timestamp
of the last transaction that wrote to X. If Tj tries to read a
value written by a transaction with a later timestamp,
the read is rejected.
o Write Rule: A transaction Tj can write to X only if the
write timestamp of X is less than the timestamp of Tj. If
a transaction tries to write to X when a transaction with
an earlier timestamp has already written to it, the write
is rejected.
3. Conflict Resolution:
o If a transaction violates the timestamp rules, it is rolled
back and restarted with a new timestamp. This ensures
that transactions are always executed in a serializable
order, based on their timestamps.
Example:
Consider two transactions T1 and T2 with timestamps TS(T1) = 1 and
TS(T2) = 2.
 T1 tries to read item X. Since TS(T1) < TS(T2), it is allowed to
read X.
 If T2 tries to write to X after T1 has read it, T2 will be allowed, as
TS(T2) > TS(T1).
If T1 attempts to write to X after T2 has written, the write is rejected, as
it violates the timestamp order.
2 How will you determine whether a schedule is serializable or not.
Discuss any locking protocol how it resolves conflicts during concurrent
execution of transactions.

Determining if a Schedule is Serializable


1. Conflict Serializability:
A schedule is conflict serializable if it can be transformed into a
serial schedule by swapping non-conflicting operations.
Steps:
o Construct a precedence graph (transactions are nodes;
directed edges show conflicts).
o If there’s a cycle in the graph, the schedule is not conflict
serializable.
2. View Serializability:
A schedule is view serializable if it is view-equivalent to a serial
schedule, where the final read/write values match.
Steps:
o Check that read and write operations produce the same
results as in a serial schedule.
Conflict Resolution in Strict 2PL:
Strict 2PL helps resolve conflicts during the concurrent execution of
transactions by ensuring the following:
1. No Conflicts on Committed Data:
o By not releasing locks until after the transaction is
committed, Strict 2PL guarantees that the changes made by
a transaction are only visible to other transactions once it is
fully committed. This prevents issues like dirty reads
(where a transaction reads data that is not yet committed).
2. Prevents Lost Updates:
o Since a transaction must hold onto its locks until it commits,
there is no possibility of another transaction overwriting its
changes before it commits. This prevents lost updates,
where concurrent transactions might overwrite each
other's changes.
3. Prevents Cascading Rollbacks:
o In normal 2PL, if a transaction fails after releasing its locks
but before it commits, any other transaction that reads its
uncommitted changes must be rolled back. This causes a
cascading rollback. Strict 2PL prevents this by ensuring a
transaction releases its locks only after it commits, ensuring
that no uncommitted changes are visible to other
transactions.
Example:
Consider two transactions T1 and T2:
 T1 starts and locks data item A for writing.
 T2 starts and attempts to read A but must wait because T1 holds
the lock.
 T1 commits and releases the lock on A. Now, T2 can read A without
interference.
By holding locks until a transaction commits, Strict 2PL ensures that no
transaction reads intermediate uncommitted data, avoiding many
concurrency-related problems.
3 What is transaction? Explain the properties of transaction.

A transaction is a unit of program execution that accesses and possibly


updates various data items.
The transaction consists of all operations executed between the
statements begin and end of the transaction. operations could include
reading, writing, updating, or deleting data.
During transaction execution, the database may be inconsistent.
When the transaction is committed, the database must be consistent.
ACID Properties:
1. Atomicity:
 Definition: A transaction is an all-or-nothing operation. Either
all operations within the transaction are completed successfully,
or none of them are. If any operation fails, the transaction is
aborted, and any changes made are rolled back to maintain the
database's integrity.
 Example: In a bank transaction, if money is debited from one
account but fails to be credited to the other account, the entire
transaction is rolled back.
2. Consistency:
 Definition: A transaction must move the database from one
consistent state to another. This means that the database should
always comply with the defined rules (constraints, integrity
conditions) before and after the transaction.
 Example: If a bank's system enforces that the sum of all accounts
should always be non-negative, a transaction should not allow the
total sum to go negative.
3. Isolation:
 Definition: The operations of a transaction are isolated from
other transactions. Even if multiple transactions are executed
concurrently, each transaction should behave as if it is the only
transaction running. This prevents the interference of one
transaction with another.
 Example: If two people try to book the last seat on a flight
simultaneously, one should succeed and the other should fail,
without creating any inconsistencies (such as both thinking they
have booked the seat).
4. Durability:
 Definition: Once a transaction is committed, its effects are
permanent and should survive any system failures. Even if the
database crashes after a transaction is committed, the changes
made by the transaction should still persist.
 Example: After transferring money from one bank account to
another, even if the system crashes right after the transaction, the
money transfer should not be lost once the transaction is
committed.
4 Explain conflict and view is serializability in detail?

5 Discuss the Recovery with Concurrent Transactions.

Module – V
1 Give a comparison of various file organizations.

2 What are the Pros and Cons of ISAM?

Indexed Sequential Access Method (ISAM) is a file organization


technique that uses both sequential storage and an index to facilitate
efficient data retrieval.

Pros of ISAM:

1. Efficient Search: The index allows for faster searches than


sequential access alone, especially for random access.

2. Supports Sequential and Random Access: ISAM allows both


sequential access to data and direct access through indexes for
faster retrieval.

3. Organized Storage: The data is organized in a way that


minimizes the time required to find records.

4. Optimized for Range Queries: The sequential nature of the data


and the index structure help in quickly retrieving ranges of data.

5. Simple Structure: Easier to implement compared to more


complex structures like B-trees.

Cons of ISAM:

1. Fixed Size of Index: The index must be periodically rebuilt or


reorganized as the file grows, which can be inefficient and time-
consuming.

2. Insertions and Deletions Overhead: As records are inserted or


deleted, the index and file need to be updated, which can lead
to fragmentation and inefficiencies.

3. Limited Flexibility: It is not as flexible as more modern indexing


methods like B-trees, particularly for handling dynamic datasets.

4. Maintenance Overhead: The need to rebuild indexes and


maintain sequential order can introduce significant overhead,
especially with large files.

5. Not Ideal for High-Concurrency Systems: ISAM does not scale


well with high-frequency updates or concurrent accesses.

3 Construct a B+ tree to insert the following key elements (order of the tree
is 3)
5, 9, 12, 16, 21, 25, 32, 34, 38, 42, 51, 55, 61, 65

4 Explain what are the differences between tree based and Hash based
indexes?

5 Explain about B+ file organization?


o B+ File Organization o B+ tree file organization is the advanced
method of an indexed sequential access method. It uses a tree-like
structure to store records in File.
o It uses the same concept of key-index where the primary key is
used to sort the records. For each primary key, the value of the
index is generated and mapped with the record.
o The B+ tree is similar to a binary search tree (BST), but it can
have more than two children. In this method, all the records are
stored only at the leaf node.
How It Works:
 Insertion: When a new record is inserted, it’s added to the
leaf node. If the leaf node is full (i.e., the maximum number
of keys is exceeded), it splits, and a new key is propagated
up to the parent node. This ensures the tree remains
balanced.
 Deletion: When a record is deleted, the corresponding key
is removed from the leaf node. If the leaf node underflows
(contains fewer than the minimum allowed keys), it may
need to merge with a sibling or borrow a key from its
sibling, keeping the tree balanced.
 Range Queries: Since the leaf nodes are linked, a range
query can be efficiently handled by starting at a leaf node
and following the links to adjacent leaf nodes until the
desired range is covered.

Advantages of B+ File Organization:


1. Efficient Search
2. Supports Range Queries
3. Ordered Data
4. Minimized Disk Access
5. Increased Fan-Out
6. Scalable for Large Datasets
Disadvantages of B+ File Organization:
1. Complex Implementation
2. Overhead for Insertions and Deletions
3. Increased Memory Usage
4. More Disk Space for Small Datasets
5. Rebalancing

You might also like