VTU DBMS Module 4 & 5 Important Questions - Answers
Q7a: Demonstrate transaction states & additional operations
Transaction States:
1. Active - Initial state where transaction is being executed.
2. Partially Committed - After the final statement is executed.
3. Committed - After successful execution, changes are saved.
4. Failed - If any error occurs during execution.
5. Aborted - After rollback due to failure.
Additional Operations:
- BEGIN: Marks start of transaction.
- COMMIT: Saves changes.
- ROLLBACK: Undoes changes.
- SAVEPOINT: Sets a point for potential rollback.
Diagram Reference: Page 2 of BCS403-module-4-pdf.pdf.
Q7b: Demonstrate working of Assertion & Triggers in database with an example
Assertions:
Used to enforce database-wide constraints.
Example:
CREATE ASSERTION SALARY_CONSTRAINT
CHECK (
NOT EXISTS (
SELECT * FROM EMPLOYEE E, EMPLOYEE M, DEPARTMENT D
WHERE E.Salary > M.Salary AND E.Dno = D.Dnumber AND D.Mgr_ssn = M.Ssn
);
Triggers:
Automatically execute on INSERT/UPDATE/DELETE.
VTU DBMS Module 4 & 5 Important Questions - Answers
Example:
CREATE TRIGGER EmpBonus
BEFORE INSERT OR UPDATE ON Employee
FOR EACH ROW
BEGIN
:NEW.bonus := :NEW.salary * 0.03;
END;
Diagram Reference: Pages 5-6 of BCS403-module-4-pdf.pdf.
Q9a: Explain the Two Phase Locking Protocol used for concurrency control
Two Phase Locking (2PL):
Ensures serializability by dividing lock operations into:
1. Growing Phase: Acquires all locks.
2. Shrinking Phase: Releases locks only after all acquisitions.
Types:
- Basic 2PL
- Strict 2PL: Holds exclusive locks until commit/abort.
- Rigorous 2PL: Holds all locks until end of transaction.
Diagram Reference: Page 4 of BCS403-module-5-pdf.pdf.
Q10a: What is NoSQL? Explain the CAP theorem
NoSQL:
Non-relational, schema-less databases designed for scalability and flexibility.
Examples: MongoDB, Cassandra, Neo4j.
CAP Theorem:
A distributed system can ensure only two of the following:
VTU DBMS Module 4 & 5 Important Questions - Answers
1. Consistency - Same data across nodes.
2. Availability - Every request gets a response.
3. Partition Tolerance - Operates despite network failures.
Diagram Reference: Page 5 of BCS403-module-5-pdf.pdf.
Q10b: What are document-based NoSQL systems? Basic CRUD in MongoDB
Document-Based NoSQL:
Stores data in JSON-like documents (BSON in MongoDB).
Schema-less and flexible.
MongoDB CRUD:
- Create: db.students.insertOne({name: "Alice", age: 21})
- Read: db.students.find({name: "Alice"})
- Update: db.students.updateOne({name: "Alice"}, {$set: {age: 22}})
- Delete: db.students.deleteOne({name: "Alice"})
Reference: Page 7 of BCS403-module-5.pdf.
Q10c: What is NoSQL Graph Database? Explain Neo4j
Graph Database:
Stores data as nodes and relationships (edges). Ideal for complex relations.
Neo4j:
Uses Cypher query language.
Example:
CREATE (a:Person {name:'Alice'})-[:KNOWS]->(b:Person {name:'Bob'})
Query:
MATCH (a:Person)-[:KNOWS]->(b:Person)
VTU DBMS Module 4 & 5 Important Questions - Answers
RETURN a.name, b.name
Reference: Page 9 of BCS403-module-5.pdf.