Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Stacks in Data Structures is a linear type of data structure that follows the LIFO (Last-In-First-Out) principle and

allows insertion and deletion operations from one end of the stack data structure, that is top.
A Stack can be used for evaluating expressions consisting of operands and operators. Stacks can be used for
Backtracking. It can also be used to convert one form of expression to another form. It can be used for systematic
Memory Management.
The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is
called a recursive function. If a function calls itself, it's known as direct recursion. This results in a one-step recursive
call. When a function is mutually called by another function in a circular manner, the function is called an indirect
recursion.
Singly linked lists is the simplest type of linked list in which every node contains some data and a pointer to the next
node of same data type.
A Queue is defined as a linear data structure that is open at both ends and the operations are performed in First In First
Out (FIFO) order. A Circular Queue is a special version of queue where the last element of the queue is connected to the
first element of the queue forming a circle. The operations are performed based on FIFO (First In First Out) principle.
The three schema architecture - This framework is used to describe the structure of a specific database system. It is
also used to separate the user applications and physical database. Contains three-levels and breaks the database down
into three different categories.
Normalization is the process of reorganizing data in a database so that it meets two basic requirements: There is no
redundancy of data, all data is stored in only one place and Data dependencies are logical, all related data items are
stored together.
Transitive dependency occurs when some non-key attribute determines some other attribute. On the other hand,
partial dependency occurs when one primary key determines some other attribute/attributes.
A weak entity is one that can only exist when owned by another one. For example: a ROOM can only exist in a
BUILDING. On the other hand, a TIRE might be considered as a strong entity because it also can exist without being
attached to a CAR. A primary key is a column -- or a group of columns -- in a table that uniquely identifies the rows of
data in that table. Deadlock is an unwanted situation in which two or more transactions are waiting indefinitely for one
another to give up locks. Deadlock is said to be one of the most feared complications in DBMS as it brings the whole
system to a Halt. Deadlock avoidance method,Transactions that access Students and Grades should always access the
tables in the same order. In this way, in the scenario described above, Transaction T1 simply waits for transaction T2 to
release the lock on Grades before it begins. When transaction T2 releases the lock, Transaction T1 can proceed freely.
Another method for avoiding deadlock is to apply both row-level locking mechanism and READ COMMITTED isolation
level. Deadlock recovery: 1.Wait-Die Scheme –If a transaction requests a resource that is locked by another transaction,
then the DBMS simply checks the timestamp of both transactions and allows the older transaction to wait until the
resource is available for execution. 2. Wound Wait Scheme –, if an older transaction requests for a resource held by a
younger transaction, then an older transaction forces a younger transaction to kill the transaction and release the
resource. The younger transaction is restarted with a minute delay but with the same timestamp. If the younger
transaction is requesting a resource that is held by an older one, then the younger transaction is asked to wait till the
older one releases it. These 2 methods of recovery difference It is based on a non-preemptive technique.It is based on
a preemptive technique.In this, older transactions must wait for the younger one to release its data items.In this, older
transactions never wait for younger transactions. The number of aborts and rollback is higher in these techniques.In
this, the number of aborts and rollback is lesser. A transitive dependency occurs when one non-prime attribute is
dependent on another non-prime attribute. If a table schema contains a dependency , where and are non-prime
attributes, we say it contains a transitive dependency. Whenever some indirect relationship happens to cause
functional dependency (FC), it is known as Transitive Dependency. Thus, if A -> B and B -> C are true, then A -> C
happens to be a transitive dependency.Thus, to achieve 3NF, one must eliminate the Transitive Dependency.
State Transition Diagram Of Transaction
Active State – When the instructions of the transaction are running then the transaction is in active state. If all
the ‘read and write’ operations are performed without any error then it goes to the “partially committed state”;
if any instruction fails, it goes to the “failed state”.
Partially Committed – After completion of all the read and write operation the changes are made in main memory or
local buffer. If the changes are made permanent on the DataBase then the state will change to “committed state” and
in case of failure it will go to the “failed state”.
Failed State –When any instruction of the transaction fails, it goes to the “failed state” or if failure occurs in making a
permanent change of data on Data Base.
Aborted State – After having any type of failure the transaction goes from “failed state” to “aborted state” and since in
previous states, the changes are only made to local buffer or main memory and hence these changes are deleted or
rolled-back.
Committed State – It is the state when the changes are made permanent on the Data Base and the transaction is
complete and therefore terminated in the “terminated state”.
Terminated State – If there isn’t any roll-back or the transaction comes from the “committed state”, then the system is
consistent and ready for new transaction and the old transaction is terminated.

The two-phase locking Protocol divides the transaction


execution phase into three components.When the transaction's execution begins in the first part, it requests
permission for the lock it requires.The transaction then obtains all of the locks in the second part. The third phase
begins when the transaction's first lock is released.The transaction cannot demand any new locks in the third phase. It
only unlocks the locks that have been acquired.A transaction follows the two-phase locking protocol if locking and
unlocking can be done in two phases. The two phases of the two-phase protocol are: 1.Growing phase: During the
growth phase, new locks on data items may be acquired, but none can be released. 2.Shrinking phase: Existing locks
may be released, but no new locks can be acquired during the shrinking phase. How Does 2PL Guarantee serialisability:
Although it is handled by the transaction manager, it does allow for the interleaving of operations. Two-phase locking
ensures that transactions which use the same objects cannot execute concurrently. This ensures that no conflicts can
happen. If interleaved transactions don't share, we know that we are safe.Two phase locking ensured serialzable
schedules using what is known as inconsistency prevention. Prevention techniques constrain the transactions to ensure
that conflicting operations can never happen. Two-phase locking does this by preventing transactions that share objects
from executing concurrently. Although inconsistency prevention is effective, it is also expensive. Perfectly safe sharing
may be prevented -- this unnecessarily reduces concurrency.

You might also like