0% found this document useful (0 votes)
36 views4 pages

VTU DBMS Module 4 & 5 Key Questions

The document outlines important questions and answers related to Database Management Systems (DBMS) covering transaction states, assertions, triggers, Two Phase Locking Protocol, NoSQL concepts, and CRUD operations in MongoDB. It explains transaction states such as Active, Committed, and Aborted, and discusses the CAP theorem in distributed systems. Additionally, it provides examples of document-based NoSQL systems and graph databases like Neo4j.

Uploaded by

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

VTU DBMS Module 4 & 5 Key Questions

The document outlines important questions and answers related to Database Management Systems (DBMS) covering transaction states, assertions, triggers, Two Phase Locking Protocol, NoSQL concepts, and CRUD operations in MongoDB. It explains transaction states such as Active, Committed, and Aborted, and discusses the CAP theorem in distributed systems. Additionally, it provides examples of document-based NoSQL systems and graph databases like Neo4j.

Uploaded by

gurumurthymk2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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 [Link].

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 [Link] > [Link] AND [Link] = [Link] AND D.Mgr_ssn = [Link]

);

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

:[Link] := :[Link] * 0.03;

END;

Diagram Reference: Pages 5-6 of [Link].

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 [Link].

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 [Link].

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: [Link]({name: "Alice", age: 21})

- Read: [Link]({name: "Alice"})

- Update: [Link]({name: "Alice"}, {$set: {age: 22}})

- Delete: [Link]({name: "Alice"})

Reference: Page 7 of [Link].

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 [Link], [Link]

Reference: Page 9 of [Link].

Common questions

Powered by AI

Assertions are used to enforce constraints that apply to the entire database, ensuring data integrity. For example, the assertion '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 ) );' checks that no employees earn more than their managers. Triggers are procedural code that automatically execute in response to certain events on a table, such as INSERT, UPDATE, or DELETE. An example of a trigger is 'CREATE TRIGGER EmpBonus BEFORE INSERT OR UPDATE ON Employee FOR EACH ROW BEGIN :NEW.bonus := :NEW.salary * 0.03; END;', which calculates and sets a 3% bonus on the new salary being inserted or updated in the employee table .

The Two Phase Locking (2PL) Protocol is a concurrency control method that ensures serializability in transactions by dividing lock operations into two phases: the Growing Phase, where transactions can acquire all the necessary locks but not release any, and the Shrinking Phase, where transactions can release locks but not acquire any new ones. There are different types of 2PL: Basic 2PL, Strict 2PL, which holds exclusive locks until a transaction is committed or aborted, and Rigorous 2PL, which holds all locks until the end of the transaction, thereby preventing any other transaction from accessing data being used by the current transaction .

Document-based NoSQL systems, like MongoDB, store data in JSON-like documents offering a flexible, schema-less design. This allows for hierarchical storage structures, efficiently managing complex data. Basic CRUD operations in MongoDB include: Create, which can be executed using 'db.students.insertOne({name: "Alice", age: 21})'; Read, using 'db.students.find({name: "Alice"})' to retrieve data; Update, utilizing 'db.students.updateOne({name: "Alice"}, {$set: {age: 22}})' to modify existing data; and Delete, with 'db.students.deleteOne({name: "Alice"})' to remove documents from collections .

Graph databases, such as Neo4j, store data as nodes and relationships (edges), making them particularly suitable for handling complex, interconnected data. They excel in applications involving social networks, recommendation engines, and networked operations where relationships are critical. Neo4j utilizes the Cypher query language for data manipulation. For example, a query like 'CREATE (a:Person {name:'Alice'})-[:KNOWS]->(b:Person {name:'Bob'})' models a relationship, which can be queried back with 'MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name'. Such features enable efficient traversal and querying of data relations .

The Two Phase Locking Protocol ensures transaction serializability by maintaining a clear separation between the growing and shrinking phases of a transaction. In the Growing Phase, a transaction can acquire all the necessary locks but is prohibited from releasing any, ensuring that once a lock is acquired, it preserves the current state from modification by other transactions. In the Shrinking Phase, the transaction can release locks but cannot acquire any new ones, preventing any subsequent transaction from accessing or affecting the resources until the locks are released. This strict management of lock operations guarantees that transactions are executed in a manner akin to serial execution, preserving data consistency and preventing anomalies like lost updates or uncommitted data reads .

NoSQL databases are non-relational databases designed to maintain scalability and flexibility, often lacking a fixed schema. Examples include MongoDB, Cassandra, and Neo4j. The CAP Theorem states that it is impossible for a distributed data store to simultaneously provide all three of the following guarantees: Consistency, ensuring the same data across nodes; Availability, ensuring that every request receives a response; and Partition Tolerance, allowing the system to continue functioning despite network failures. Distributed system designs must choose which two of these they prioritize .

Triggers enhance data integrity and automation by automatically enforcing rules and executing procedures in response to specified events such as INSERT, UPDATE, or DELETE operations. By doing so, they ensure that business rules and data constraints are consistently applied without manual intervention. For instance, a trigger might automatically calculate and update a bonus whenever an employee's salary record is modified, ensuring financial records remain accurate and consistent. This not only reduces human error but also streamlines processes by eliminating the need for manual checks or adjustments, ultimately improving the reliability and consistency of database operations .

In a database management system, transactions go through several states: Active, Partially Committed, Committed, Failed, and Aborted. 1. Active: The initial state where the transaction is in progress. 2. Partially Committed: When the final statement of the transaction has been executed but not yet saved. 3. Committed: After successful execution, indicating that changes have been made permanent. 4. Failed: If an error occurs during execution, the transaction enters this state. 5. Aborted: After a transaction is rolled back due to failure. Additional operations include: BEGIN, which marks the start of a transaction; COMMIT, which saves the changes made during the transaction; ROLLBACK, which undoes changes; and SAVEPOINT, which sets a point to which a transaction can roll back instead of rolling all the way back .

Rollback operations in transaction management are critical for maintaining database integrity and reliability. They allow a database to revert to a known consistent state in the event of transaction failure, preventing partial transactions from corrupting the database. By providing a mechanism to undo changes made by the transaction that failed, rollback operations protect data integrity and ensure that only successfully completed transactions (those that reach the commit state) affect the database. This capability is essential to support the ACID properties—specifically, atomicity—ensuring transactions are all-or-nothing processes .

NoSQL databases are preferred over traditional relational databases when dealing with large volumes of diverse data types that require high scalability, flexibility, and fast performance without a predefined schema. Applications such as social networking sites, real-time analytics, content management systems, and other domains experiencing rapid iterative development benefit from NoSQL's ability to efficiently manage extensive, semi-structured data and horizontal scaling. Additionally, use cases requiring quick adaptability to changing data models, such as Big Data applications, are suited for NoSQL due to its schema-less nature and support for distributed computing .

You might also like