DBMS 01
DBMS 01
of Pages :
INSTRUCTIONS TO CANDIDATES :
SECTION-A:
Integrity constraints are rules enforced on data in a database to ensure accuracy and
consistency. They prevent invalid data entry and maintain the integrity of the database.
Common types of integrity constraints include:
Lossless decomposition is the process of breaking down a relation (table) into two or more
smaller relations while ensuring no data is lost and the original relation can be reconstructed
using a natural join.
Example:
If R(A, B, C) is decomposed into R1(A, B) and R2(B, C), it is lossless if R1 ⋈ R2 = R.
3. What are the characteristics of the 3-tier architecture of a database?
The 3-tier architecture separates the database system into three layers:
Isolation ensures that transactions are executed independently without interference from other
transactions. It prevents concurrent transactions from affecting each other’s intermediate
states.
Tertiary storage refers to a storage system used for archival purposes, providing large
capacity at a low cost.
Examples: Magnetic tapes, optical discs.
It is slower compared to primary (RAM) and secondary storage (HDD/SSD) and is typically
used for backups or rarely accessed data.
6. Define authorization.
A serializable schedule is one that ensures concurrent transaction execution results in a state
equivalent to transactions executed serially (one after the other).
Query optimization is the process of improving the efficiency of SQL queries to reduce
execution time and resource usage.
Steps:
SQL injection is a type of security attack where malicious SQL statements are inserted into
input fields to manipulate or exploit a database.
Example:
SELECT * FROM Users WHERE Username = 'admin' --' AND Password = 'xyz';
Prevention Methods:
1. What are the benefits of extended features of the ER model? Draw any ER model
using extended features.
2. Explain the difference between Cartesian product and natural join with an example.
Cartesian Product:
• Combines every row of one table with every row of another table.
• Results in an exhaustive pairing of rows, leading to a large dataset.
• Syntax: SELECT * FROM Table1, Table2;
• Example:
Tables:
o Table1: A = {1, 2}
o Table2: B = {x, y}
Cartesian product: {(1, x), (1, y), (2, x), (2, y)}
Natural Join:
• Combines tables based on common attributes (matching column names and values).
• Filters out rows that do not match the join condition.
• Syntax: SELECT * FROM Table1 NATURAL JOIN Table2;
• Example:
Tables:
o Table1: {(ID: 1, Name: John), (ID: 2, Name: Jane)}
o Table2: {(ID: 1, Age: 25), (ID: 3, Age: 30)}
Natural join: {(ID: 1, Name: John, Age: 25)}
Hashing:
Hashing is a data indexing technique where a hash function converts input (key) into a fixed-
size integer value called a hash code or hash value.
How It Works:
Advantages:
4. What do you mean by locks in transaction processing? How are locks implemented?
1. Shared Lock (S): Allows multiple transactions to read but not write.
2. Exclusive Lock (X): Allows a transaction to read and write, preventing other
transactions from accessing.
Implementation of Locks:
1. Labels: Data and users are classified into categories (e.g., Confidential, Secret).
2. Policy Enforcement: Central authority defines access policies.
3. No User Modification: Users cannot modify access permissions.
How It Works:
Example:
• A user with "Secret" clearance can access "Confidential" and "Secret" data but not
"Top Secret" data.
Advantages:
SECTION-C
Key Aspects:
1. Foreign Key: The column in the child table that references the primary key in the
parent table.
o Example: In the Orders table, the CustomerID column is a foreign key
referencing the CustomerID column in the Customers table.
2. Actions on Referential Integrity:
o CASCADE: If a referenced record is deleted or updated, all dependent records
are deleted or updated.
o SET NULL: Sets the foreign key to NULL if the referenced record is deleted.
o RESTRICT/NO ACTION: Prevents deletion or updating of referenced
records.
Example Schema:
Importance:
Characteristics:
Advantages:
1. Efficiency: Direct links enable fast data retrieval for complex queries.
2. Flexibility: Supports complex relationships, such as many-to-many.
3. Data Integrity: Parent-child relationships maintain referential integrity.
Drawbacks:
Concurrency Control
Concurrency control ensures that multiple transactions can execute simultaneously without
violating data consistency and integrity.
• Purpose: Avoid problems such as lost updates, dirty reads, and uncommitted data
dependencies.
• Techniques: Locking, timestamp ordering, and optimistic concurrency control.
1. Lost Update: Occurs when two transactions simultaneously update the same data,
and one update overwrites the other.
o Example:
▪ Transaction A reads balance = 100.
▪ Transaction B reads balance = 100.
▪ A adds 50 → balance = 150.
▪ B deducts 30 → balance = 70. (overwrites A's update).
2. Dirty Read: A transaction reads data modified by another transaction that is not yet
committed.
o Example:
▪ Transaction A updates balance = 150 but hasn’t committed.
▪ Transaction B reads balance = 150.
▪ If A rolls back, B has read invalid data.
3. Uncommitted Dependency: A transaction depends on uncommitted changes made
by another transaction.
o Example:
▪ Transaction A updates salary = 1000.
▪ Transaction B calculates tax based on the new salary.
▪ A rolls back; B's calculation is invalid.
4. Deadlock: Two or more transactions wait indefinitely for each other to release
resources.
o Example:
▪ Transaction A locks row X, waits for row Y.
▪ Transaction B locks row Y, waits for row X.
• SQL Injection.
• Privilege Escalation.
• Unauthorized Data Access.
Prevention Measures: