Module 5 - Concurrency Control and NoSQL (VTU DBMS)
1. Concurrency Control Using Timestamp Ordering:
Each transaction is assigned a unique timestamp when it starts. This timestamp is used to order the
operations. When a transaction reads or writes, it is allowed only if it does not conflict with more
recent transactions. Otherwise, it is aborted. This helps maintain consistency and avoids conflicts.
2. Multiversion Concurrency Control (MVCC):
MVCC stores multiple versions of a data item. Transactions read the latest version valid at their start
time. Writers create a new version instead of modifying the existing one. This avoids read-write
conflicts and increases system concurrency.
3. Document-Based NoSQL Databases:
Stores data in document formats like JSON or BSON. Each document can have a different structure
(schema-less). Example: MongoDB. Documents contain key-value pairs and support nested objects.
They are flexible, scalable, and used in dynamic web applications.
4. Neo4j Data Model:
Neo4j is a graph database with nodes (entities), relationships (edges), and properties (key-value
pairs). Useful for connected data like social networks. Example: (Alice)-[:FRIEND]->(Bob). Cypher is
the query language used in Neo4j.
5. Two-Phase Locking (2PL):
2PL ensures serializability using two phases:
- Growing: transaction acquires all required locks.
- Shrinking: transaction releases locks and cannot acquire more.
Strict 2PL holds exclusive locks until commit. It ensures conflict-free execution but can lead to
deadlocks.
6. CAP Theorem:
CAP stands for Consistency, Availability, and Partition Tolerance. The theorem says that in a
distributed system, only two out of three can be guaranteed at a time. For example, MongoDB
chooses Availability and Partition Tolerance (AP).
7. MongoDB CRUD Operations:
- Create: [Link]({ name: "John", age: 25 });
- Read: [Link]({ age: { $gt: 20 } });
- Update: [Link]({ name: "John" }, { $set: { age: 26 } });
- Delete: [Link]({ name: "John" });
These operations help manage documents efficiently.