1 - Dbms Module 5
1 - Dbms Module 5
com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
SYLLABUS
• Transaction Processing Concepts - overview of concurrency control,
Transaction Model, Significance of concurrency Control & Recovery,
Transaction States, System Log, Desirable Properties of transactions.
Serial schedules, Concurrent and Serializable Schedules, Conflict
equivalence and conflict serializability, Recoverable and cascade-less
schedules, Locking, Two-phase locking and its variations.
• Log-based recovery, Deferred database modification, check-pointing.
• Introduction to NoSQL Databases, Main characteristics of Key-value DB
(examples from: Redis), Document DB (examples from: MongoDB)
• Main characteristics of Column - Family DB (examples from: Cassandra)
and Graph DB (examples from : ArangoDB)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Transaction
• It is a group of database commands that can change/
access the data stored in a database
• Eg: Accounts
// Transfer Rs. 100 from Mark’s Account to Mary’s
Id Name Balance account
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
TERMINOLOGY
• BEGIN TRANSACTION
▫ Begining of transaction execution
• END TRANSACTION
▫ Transaction execution is completed
• ROLLBACK_TRANSACTION(ABORT)
▫ This signals that the transaction has ended unsuccessfully, so
that any changes made by that transaction must be undone
• COMMIT_TRANSACTION
▫ Signals successful end of the transaction. All changes made by
the transaction are recorded permanently in the database and
will not be undone
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
TRANSACTION PROCESSING
• A database is a collection of named data items
• Granularity of data
▫ the size of a data item
▫ a field, a record , or a whole disk block (Concepts are independent of
granularity)
• Basic database access operations are read and write
▫ read_item(X): Reads a database item named X into a program variable
also named X.
▫ write_item(X): Writes the value of program variable X into the
database item named X.
• Basic unit of data transfer from the disk to the computer main
memory is one block. A data item (what is read or written) will be the
field of some record in the database, although it may be a larger unit
such as a record or even a whole block.
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
read_item(X) command
• read_item(X) command includes the following steps:
▫ Find the address of the disk block that contains item X.
▫ Copy that disk block into a buffer in main memory (if
that disk block is not already in some main memory
buffer).
▫ Copy item X from the buffer to the program variable
named X.
PREPARED BY SHARIKA T R,
SNGCE
write_item(X) command
• write_item(X) command includes the following steps:
▫ Find the address of the disk block that contains item X.
▫ Copy that disk block into a buffer in main memory (if that disk
block is not already in some main memory buffer).
▫ Copy item X from the program variable named X into its correct
location in the buffer.
▫ Store the updated block from the buffer back to disk (either
immediately or at some later point in time).
• the decision about when to store a modified disk block whose
contents are in a main memory buffer is handled by the recovery
manager of the DBMS in coop_x0002_eration with the
underlying operating system.
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
5. Disk failure:
Some disk blocks may lose their data because of a read
or write malfunction or because of a disk read/write
head crash. This may happen during a read or a
write operation of the transaction.
6. Physical problems and catastrophes:
This refers to an endless list of problems that includes
power or air-conditioning failure, fire, theft,
sabotage, overwriting disks or tapes by mistake, and
mounting of a wrong tape by the operator.
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
States of a Transaction
• Active
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Redoing transactions
• Transactions that have written their commit entry in
the log must also have recorded all their write
operations in the log; otherwise they would not be
committed, so their effect on the database can be
redone from the log entries. (Notice that the log file
must be kept on disk.
• At the time of a system crash, only the log entries that
have been written back to disk are considered in the
recovery process because the contents of main memory
may be lost.)
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Atomicity
• A transaction is said to be atomic if either all of the commands are
succeeded or none of them
• Responsibility of Recovery Subsystem
• Eg; Transfer Rs. 100 from A to B:
BEGIN TRANSACTION
R(A);
A=A-100;
Either execute all command or no
W(A); command at all
R(B);
B=B+100;
W(B)
END TRANSACTION
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Consistency
• A transaction should be consistency preserving
• It should take the database from one consistent sate to
another
• Reponsibility of Programers who wrote the database
programs
• Eg: Transfer Rs. 100 from A to B
A=1000 A=900
B=1000 B=1100
Total=2000 Total=2000
PREPARED BY SHARIKA T R,
SNGCE
Isolation
• Transactions should be isolate to each other during
concurrent execution
• Responsibility: Cocurrent control subsystem
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Durability or Permanency
• The changes applied to the database by committed
transaction must persist in the database
• these changes must not be lost because of any failure
• Responsibility of Recovery Subsystem
PREPARED BY SHARIKA T R,
SNGCE
Schedules(Histories) of Transactions
• A schedule S of n transactions T1, T2,.. Tn is an ordering of
the operation of the transactions
• When transactions are executing concurrently in an
interleaved fashion, the order of execution of operations
from the various transactions forms what is known as a
transaction schedule (or history).
1. Serial Schedule
2. Non Serial Schedule
3. Serializable Schedule
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
Serial Schedule
PREPARED BY SHARIKA T R,
SNGCE
Serial Schedule A B C
Serial Schedule A B C
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
SNGCE
Schedule S2
T1 T2
R(A)
A=A+50
R(A)
A=A+40 Initially Final Value
W(A) A=100 A=150
W(A) B=200 B=170
R(B)
B=B-30 Schedule S2 gives the erroneous
R(B) result
B=B-60 not same as serial schedule
W(B)
W(B)
PREPARED BY SHARIKA T R,
SNGCE
Summary
• Serial Schedules always gives correct result
• But there are some drawbacks
• In order to avoid that we introduced non serial schedules
• But not all non serial schedules are correct
• So we need a non serial schedule which always give a
correct result
• or Equivalent to a Serial Schedule = Serializable Schedule
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Serializable Schedule
• A non serial schedule of n transactions is said to be
serializable if it is equivalent to some serial schedule of
same n transactions
• Every serializable schedules are considered as correct
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Result equivalence
• Two schedules are said to be result equivalent if they
produce the same final state of the database they produce
same result
For X=100: S1 & S2 are result
S1 S2
equivalent
read_item(X); read_item(X); But for other values, not result
X:=X+10; X:=X*1.1; equivalent
write_item(X); write_item(X);
//S1 and S2 should not be considered
equivalent
PREPARED BY SHARIKA T R,
SNGCE
Conflict equivalence
• Conflict Operations
▫ Two operations in a schedule are said to conflict if they satisfy
1. They belong to different transactions
2. They access the same data item
3. At least one of the operation is a write operation
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
• Eg: Schedule S:
R1(X) W2(X) : Conflict
R2(X) W1(X) :Conflict
W1(X) W2(X) :Conflict
R1(X) R2(X) :No Conflict
W2(X) W1(Y) :No Conflict
R1(X) W1(X) :No Conflict
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Conflict Equivalence
• Two schedules are said to be conflict equivalent if the
relative order of any two conflicting operations is the same
in both schedules
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Rule 2
S2:
T1 T2 A
W(A) T1 T2
W(A)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Rule 3
S3:
T1 T2 A
W(A) T1 T2
R(A)
PREPARED BY SHARIKA T R,
SNGCE
Rule 4
S4:
T1 T2
R(A) T1 T2
R(A)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Rule 5
S5:
T1 T2 A
W(A) T1 T2
R(A)
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
serializing order
S3
T1 T2 T3
R(A)
W(B) A
T1 T2
R(B)
R(A)
W(A) A B
R(A) T3
PREPARED BY SHARIKA T R,
SNGCE
Step 1: Remove
Serializing order node with
least indegree Step 2: Remove
T2 NEXT node with
least indegree T1
A
T1 T2 T1
T3
A B A
T3
T3
SERIALIZING ORDER= T2 T1 T3
PREPARED BY SHARIKA T R,
SNGCE
View Equivalence
• Two schedules S1 and S2 are said to be view equivalent if
for each data item,
▫ If the initial read in S1 is done by Ti, then same transaction
should be done in S2 also
▫ If the final write in S1 is done by Ti, then in S2 also Ti should
perform the final write
▫ If Ti reads the item written by Tj in S1, then S2 also Ti should
read the item written by Tj
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
S1 S2: T1T2
T1 T2 T1 T2
R(A) R(A)
W(A) W(A) S1 and S2 is view
R(B) serializable
R(A) hence serializable
W(A) W(B)
R(A)
R(B) W(A)
W(B) R(B)
R(B) W(B)
W(B)
Initial read in S1 by T 1 and S2 T2
Final write in S1 is by T2 AND S2 is by T2
Writer reader conflict in data item is same sequence in both S1 AND s2
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Important Points
• Every Conflict serializable schedule is View Serializable but
vice versa is not true
• Every Conflict Serializable schedule is Serializable but vice
versa is not true
• Every View Serializable schedule is serializable and vice
versa is also true
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
S1
T1 T2 T3
R(A)
W(A)
W(A)
W(A)
If there exist blind write, then the schedule may or may not be view
serializable. The follow Normal Procedure
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Irrecoverable Schedule
• If a transaction Tj reads a data item written by transaction
Ti and commit operation of T j is before the commit of Ti,
then such schedules are irecoverable
S
T1 T2 Initially A=10
R(A) Here T2 is not recoverable ie
A=A-20 //A=-10 irrecoverable
W(A) T2 performs a dirty read
R(A) //A=-10
Commit; // A=-10 is permanent
R(B)
W(B) if T1 fails here t1 should roolback A to 10 but
Commit; A’s value is already committed. It cannot
rollback. A=-10 is an invalid value
PREPARED BY SHARIKA T R,
SNGCE
Recoverable Schedules
• If a transaction Tj reads a data item written by transaction
Ti, then the commit operation of T j should happen only
after the commit Ti, then such schedules are recoverable
• Tht is Writer_transaction should commit first, then
Reader_transaction commit (Recoverable Schedules)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
S
First T1 has first write so it must
T1 T2
commit here it is so.
R(A)
W(A) //A=10 So T2 is recoverable in case if
R(A) there is a failure in T1
R(B)
W(B)
Commit;
Commit;
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2
W(A)
R(A) Irrecoverable
Commit;
Commit;
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2
R(A) Recoverable
W(A)
Commit;
W(A) //Blind Write
Commit;
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2 T3
R(A)
W(A) Recoverable
R(A)
W(A) The problem with above
R(A) schedule is cascading
W(A) rollback/aborts
C1;
C2
C3
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Cascading Rollbacks
• Because of a single failure in a particular transaction, if all
dependent transactions need to be rolled back, it is called
as cascading rollbacks
• Such schedules are recoverable, but can be time consuming
since numerous transaction csn be rolled back
• Complete waste of work, time and resources
• To avoid cascading rollbacks, we need Cascadeless
schedules
PREPARED BY SHARIKA T R,
SNGCE
Cascadeless Schedules
• Schedule which are free from Cascading Rollbacks
• If every transaction in the schedule reads only items that
were written by committed transaction, then such a
schedule is called Cascadeless schedules
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2 T3
Recoverable and
R(A) Cascadeless
W(A)
C1; Every cascadeless
R(A) schedules are
W(A) Recoverable but vice
C2 versa is not true
R(A)
W(A)
C3
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2
R(A)
R(B) Recoverable NOT Cascadeless
W(B)
W(A) Cascading rollbacks/ abort
R(B) possible
C;
C;
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Strict Schedule
• More restrictive type of schedule
• In a schedule, a transaction is neither allowed to read/write
a data item until the transaction that has write is
committed or aborted
S
T1 T2
Recoverable, Cascadeless,
W(A) Not Strict
W(A)
C;
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2 Recoverable, Cascadeless,
W(A) Strict
C
R(A)/W(A)
C;
PREPARED BY SHARIKA T R,
SNGCE
Concurrency Problems
• When multiple transactions are running concurrently in an
uncontrolled or unrestricted manner in a schedule, then it
might lead to several problems
1. Dirty Read Problem
2. Unrepeatable Read Problem
3. Lost Update Problem
4. Phantom Read Problem
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Here T1 is not able to repeat the same read. T1 Wonders how the value of Y
got changed because according to it, it is running in isolation
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
S
T1 T2
Select * from Employee
where Id between 1 and 3
// 2 rows
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Types of Lock
• Two type of Locks are
1. Shared Lock(S(A))
2. Exclusive Lock(X(A))
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Shared Lock
• If a transaction wants to perform read operation on a data
item, it should apply shared lock on that item
T1
S(A)
Read(A)
PREPARED BY SHARIKA T R,
SNGCE
Exclusive Lock
• If a transaction acquire this lock, it can perform
read/write/both operation on that data item
T1
X(A)
Read(A)
Write(A)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Case 1
• Multiple transactions can perform read operation on same
data item at the same time
• More thane one shared locks are possible
T1 T2 . . . ... Tn
S(A)
R(A)
S(A)
R(A)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Case 2
• If any transaction want to apply an exclusive lock on data
item on which already a shared lock is allowed for some
other transaction is Not Possible
T1 T2 Tn
S(A)
R(A)
S(A)
R(A)
X(A)//Not allowed
W(A)
PREPARED BY SHARIKA T R,
SNGCE
T1 T2 Tn
S(A)
R(A)
S(A)
R(A)
U(A)
U(A)
X(A)//allowed
W(A)
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
S(A)
R(A)
S(B)
R(B)
U(A)
X(A)
R(A)
B is not unlocked.
X(B) so this exclusive lock is not
R(B) possible
So NOT Lock
Compatible
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
S(A)
R(A)
U(A)
S(B) So Lock Compatible
R(B)
X(A) This is called as Simple
W(A) Locking Protocol
S(B)
R(B)
U(A)
U(B)
U(B)
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Important Points
• Every transaction should first perform Growing phase and
then Shrinking phase
• After Shrinking phase, Growing phase is not possible
• Growing phase is compulsory, but shrinking phase is
optional
• 2PL schedules are always Conflict Serializable but vice
versa is not true
• Lock point: The point at which a transaction acquire the
last lock
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
T1 T2
S(B)
X(A)//LP
R(B)
S(B)
R(B) First Write so first commit
R(A) should be first done by T1 but
W(A) T2 comit first, so this is
U(A) irrecoverable
X(A)//LP
R(A)
W(A)
U(A) Lock Compatible,
C; 2PL,
C; Irrecoverable
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
T1 T2 T3
X(A)//LP
R(A)
W(A)
U(A)
X(A)//LP
R(A)
W(A)
U(A) Lock Compatible,
C; 2PL,
S(A)//LP Recoverable
R(A) NOT Cascadeless
C;
C;
T1 T2
X(A) X(B)
R(A) R(B)
W(A) W(B)
********* **********
Wants to update B Wants to update A
********* **********
Here none of the transaction can continue. None of them will release
the locks
Because once they release any locks then it is not possible to lock any
data item
This will leads to deadlock
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Variations of 2PL
1. Strict 2PL
2. Rigorous 2PL
3. Conservative 2PL
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Strict 2PL
• Follow basic 2PL + All exclusive locks should unlock only
after commit operation
• Strict Schedule
▫ A transaction is neither allowed to read/write a data item
until the transaction that has written is committed
T1 T2
W(A)
C;
R(A)/W(A) //Strict Schedule
PREPARED BY SHARIKA T R,
SNGCE
T1 T2
X(A)
R(A)
S(B)
R(B)
S(B)
R(B)
W(A)
U(B)
C;
U(A) Exclusive lock on A unlocked
after comit(unlock not
X(A) mandatory)
R(A) Lock Compatible,
W(A); 2PL, Strict 2PL
C;
PREPARED BY SHARIKA T R,
SNGCE
Rigorous 2PL
• More stronger than Strict 2PL
• Follow basic 2PL + All locks (both exclusive and shared
locks) should unlock only after commit operation
• Every Rigorous 2PLis Strict 2PL but vice versa is not true
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
T1 T2
S(A)
R(A)
S(B)
R(B)
X(C)
R(C)
W(A)
C
U(B);
U(C) Rigorous 2PL & Strict
S(C) 2PL
R(C)
C;
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Conservative 2PL(C2PL)
• No DEADLOCK
• Follow Basic 2PL + All transaction should obtain all lock
they need before the transaction begins
• Release all lock after commit
• Recoverable, Serializable, Casadeless, Deadlock Free
• Not practical to implement
PREPARED BY SHARIKA T R,
SNGCE
T2 CAN START
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Log-based recovery
• A Log is the most widely used structure for recording database
modifications.
• Update log record: It describes a single database write. It has
following fields-
▫ Transaction identifier is the unique identifier of the transaction
that performed the write operation.
▫ Data item identifier is the unique identifier of the data item written.
▫ Old value is the value of the data item prior to the write.
▫ New value is the value of the data item that it will have after the
write.
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Checkpointing Protocol
• All committed transactions in the log file before checkpoint
are permanently saved on the disk. So no need to anything
• All committed tansactions after checkpoint should be
redone (redo list)
• All uncommitted transactions (before and after checkpoint)
should be undone (undo list)
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
NoSQL
• NoSQL database stands for “Not Only SQL” or “Not SQL.”
• It is a non-relational Data Management System, that does
not require a fixed schema.
• It avoids joins, and is easy to scale. The major purpose of
using a NoSQL database is for distributed data stores with
humongous data storage needs.
• NoSQL is used for Big data and real-time web apps.
• For example, companies like Twitter, Facebook and Google
collect terabytes of user data every single day
PREPARED BY SHARIKA T R,
SNGCE
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Features of NoSQL
PREPARED BY SHARIKA T R,
SNGCE
• Non-relational
▫ NoSQL databases never follow the relational model
▫ Never provide tables with flat fixed-column records
▫ Work with self-contained aggregates or BLOBs
▫ Doesn’t require object-relational mapping and data normalization
▫ No complex features like query languages, query planners,referential
integrity joins,
• ACID
▫ Schema-free
▫ NoSQL databases are either schema-free or have relaxed schemas
▫ Do not require any sort of definition of the schema of the data
▫ Offers heterogeneous structures of data in the same domain
PREPARED BY SHARIKA T R,
SNGCE
Types of NoSQL
• NoSQL Databases are mainly categorized into four types:
▫ Key-value Pair Based
▫ Column-oriented
▫ Graphs based
▫ Document-oriented
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Column Oriented
• While a relational database stores data in rows and reads data row
by row, a column store is organized as a set of columns.
• When you want to run analytics on a small number of columns,
you can read those columns directly without consuming memory
with the unwanted data.
• Columns are often of the same type and benefit from more
efficient compression, making reads even faster.
• Columnar databases can quickly aggregate the value of a given
column (adding up the total sales for the year, for example). Use
cases include analytics.
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
PREPARED BY SHARIKA T R,
SNGCE
• The Row Key is exactly that: the specific identifier of that row and is always
unique.
• The column contains the name, value, and timestamp, so that’s
straightforward. The name/value pair is also straight forward, and the
timestamp is the date and time the data was entered into the database.
• Some examples of column-store databases include Casandra, CosmoDB,
Bigtable, and HBase.
PREPARED BY SHARIKA T R,
SNGCE
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
Use Cases
• Developers mainly use column databases in:
▫ Content management systems
▫ Blogging platforms
▫ Systems that maintain counters
▫ Services that have expiring usage
▫ Systems that require heavy write requests (like log
aggregators)
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
Visit my YouTube channel for lectures: https://www.youtube.com/c/sharikatr
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE
PREPARED BY SHARIKA T R,
SNGCE