SlideShare a Scribd company logo
1 of 67
Database Management
Systems -20ISE43A
TEXT BOOKS:
1. Abraham Silberschatz, Henry F. Korth, S. Sudharshan,
ā€œDatabase System Conceptsā€, Sixth Edition, Tata McGraw
Hill, 2013.
2. Ramez Elmasri, Shamkant B. Navathe, ā€œFundamentals
of Database S y s t e m sā€ , Sixth Edition, Pearson /
Addison - Wesley, 7th Edition 2017
REFERENCES:
1. Raghu Ramakrishnan, ā€œDatabase Management
Systemsā€, Third Edition, McGraw Hill, 2013.
MODULE 1-Introduction: Introduction, An example, Characteristics of
Database Approach. Database Applications: Need for data
management, Advantages of using DBMS approach. Data models &
Database Architecture: Data models, schemas and instances, Three-
schema architecture and data independence, Centralized and client-
server architectures.
MODULE 2-ER Diagrams: Entity Types, Entity Sets, Attributes and Keys,
Relationship types, Roles and Structural Constraints, Weak Entity Types,
ER Diagrams.
MODULE 3-Relational Model: ER to Relational Mapping, Constraints,
Keys Dependencies. Functional Dependencies: Normalization First,
Second, Third & Fourth Normal Forms, BCNF.
MODULE 4-Relational Algebra: Update Operations, Unary Relational
Operations: SELECT and PROJECT, Relational Algebra Operations from
Set Theory, Binary Relational Operations: JOIN and DIVISION;
Additional Relational Operations; Examples of Queries in Relational
Algebra; Relational Database Design Using ER- to-Relational Mapping.
MODULE 5-Advanced SQL & Transaction Management : Embedded
& Dynamic SQL , Stored procedures, More complex SQL Queries,
Transaction concepts, Transaction state, Implementation of Atomicity
& Durability, Concurrent executions, Seializability
CO1
Understand the database concepts, different database models, and
database management systems and design database schema
CO2
Develop the ER structures for real world examples using the concept
of Entity Relationship models with constraints and cardinalities.
CO3
Understand the concepts of Normalization and design database
which possess no anomalies.
CO4
Apply the concepts of relational database theory to manage
relational database management system.
CO5
Apply the concepts of triggers, embedded and dynamic SQL.
CO6
Implement database applications in SQL.
Engineered for Tomorrow
Advanced SQL & Transaction Management :
Embedded & Dynamic SQL , Stored procedures, More complex SQL
Queries, Transaction concepts, Transaction state, Implementation of
Atomicity & Durability, Concurrent executions, Seializability
Embedded SQL
Cursors
Dynamic SQL
Static (embedded) SQL:
1.In static SQL how database will be accessed is predetermined in the
embedded SQL statement.
2.It is more swift and efficient.
3.SQL statements are compiled at compile time.
4.Parsing, validation, optimization, and generation of application plan
are done at compile time.
5.It is generally used for situations where data is distributed
uniformly.
6.EXECUTE IMMEDIATE, EXECUTE and PREPARE statements are not
used.
Dynamic (interactive) SQL:
1.In dynamic SQL, how database will be accessed is determined at run
time.
2.It is less swift and efficient.
3.SQL statements are compiled at run time.
4.Parsing, validation, optimization, and generation of application plan
are done at run time.
5.It is generally used for situations where data is distributed non-
uniformly.
6.EXECUTE IMMEDIATE, EXECUTE and PREPARE statements are used.
7.It is more flexible.
Database Stored Procedures and Functions
ā€¢ The machine where the program is executing is different from the machine on
which the database serverā€” and the main part of the DBMS software packageā€”is
located. Although this is suitable for many applications, it is sometimes useful to
create database program modulesā€”procedures or functionsā€” that are stored and
executed by the DBMS at the database server.
ā€¢ These are historically known as database stored procedures, although they can be
functions or procedures.
ā€¢ The term used in the SQL standard for stored procedures is persistent stored
modules because these programs are stored persistently by the DBMS, similarly to
the persistent data stored by the DBMS.
Stored procedures are useful in the following circumstances:
ā€¢ If a database program is needed by several applications, it can be
stored at the server and invoked by any of the application
programs. This reduces duplication of effort and improves
software modularity.
ā€¢ Executing a program at the server can reduce data transfer and
communication cost between the client and server in certain
situations.
ā€¢ These procedures can enhance the modeling power provided by
views by allowing more complex types of derived data to be made
available to the database users.
ā€¢ Additionally, they can be used to check for complex constraints
that are beyond the specification power of assertions and triggers.
In general, many commercial DBMSs allow stored procedures and functions to be
written in a general purpose programming language.
Alternatively, a stored procedure can be made of simple SQL commands such as
retrievals and updates. The general form of declaring stored procedures is as follows:
The parameters and local declarations are optional, and are specified only if needed. For
declaring a function, a return type is necessary, so the declaration form is
If the procedure (or function) is written in a general-purpose programming language, it is
typical to specify the language as well as a file name where the program code is stored. For
example, the following format can be used:
ā€¢ In general, each parameter should have a parameter type that is one of the
SQL data types. Each parameter should also have a parameter mode, which is
one of IN, OUT, or INOUT.
ā€¢ These correspond to parameters whose values are input only, output
(returned) only, or both input and output, respectively.
ā€¢ Because the procedures and functions are stored persistently by the DBMS, it
should be possible to call them from the various SQL interfaces and
programming techniques.
ā€¢ The CALL statement in the SQL standard can be used to invoke a stored
procedureā€”either from an interactive interface or from embedded SQL or
SQLJ.
ā€¢ The format of the statement is as follows:
Transaction States
A transaction is a unit of program execution that accesses and possibly updates
various data items.
Seializability
Serializable Schedule
A serial schedule is always a serializable schedule because
any transaction only starts its execution when another
transaction has already completed its execution. However, a
non-serial schedule of transactions needs to be checked for
Serializability.
Note: If a schedule of concurrent ā€˜n' transactions can be
converted into an equivalent serial schedule. Then we can
say that the schedule is serializable. And this property is
known as serializability.
Testing of Serializability
To test the serializability of a schedule, we can use the
serialization graph.
Suppose, a schedule S. For schedule S, construct a graph
called as a precedence graph. It has a pair G = (V, E), where E
consists of a set of edges, and V consists of a set of vertices.
The set of vertices contain all the transactions participating
in the S schedule. The set of edges contains all edges Ti ->Tj
for which one of the following three conditions satisfy:
Create a node Ti -> Tj if Ti transaction executes write (Q)
before Tj transaction executes read (Q).
Create a node Ti -> Tj if Ti transaction executes read (Q)
before Tj transaction executes write (Q).
Create a node Ti -> Tj if Ti transaction executes write (Q)
before Tj transaction executes write (Q).
Schedule S:
If a precedence graph for any schedule contains a
cycle, then that schedule is non-serializable. If the
precedence graph has no cycle, then the schedule is
serializable.
So, schedule S is serializable (i.e., serial schedule)
because the precedence graph has no cycle
Precedence graph of Schedule S1
Types of Serializability
Conflict Serializability
View Serializability
Conflicting operations
The two operations are called conflicting operations, if all
the following three conditions are satisfied:
Both the operation belongs to separate transactions.
Both works on the same data item.
At least one of them contains one write operation.
Note: Conflict pairs for the same data item are:
Read-Write
Write-Write
Write-Read
Conflict Equivalent Schedule
Two schedules are called as a conflict equivalent schedule if
one schedule can be transformed into another schedule by
swapping non-conflicting operations.
Example of conflict serializability:
After all the steps, the precedence graph will be ready, and it
does not contain any cycle or loop, so the above schedule S2
is conflict serializable. And it is equivalent to a serial
schedule.
PL/SQL - Basic Syntax
PL/SQL which is a block-structured language; this means that the PL/SQL programs are divided
and written in logical blocks of code. Each block consists of three sub-parts āˆ’
Every PL/SQL statement ends with a semicolon (;). PL/SQL blocks can be
nested within other PL/SQL blocks using BEGIN and END. Following is
the basic structure of a PL/SQL block āˆ’
1
2
3
4
5
6
7
8
9
10
11
Declare
Var1 integer;
Var2 integer;
Var3 integer;
Begin
Var1:=&var1;
Var2:=&var2;
Var3:=var1+var2;
Dbms_output.put_line(var3);
End;
/
PL/SQL Program To Add Two Numbers
View Serializability In DBMS
ā€¢ If a schedule is view equivalent to a serial schedule, then it
will be view serializable
ā€¢ If the schedule is serializable via conflict, then it shall be
view serializable as well.
ā€¢ The view serializable which has no conflict serializable has
blind writes.
View Equivalent
Schedules S1 and schedule S2 will; be view equivalent if the
following conditions are satisfied:
View Equivalent
Two schedules S1 and S2 are said to be view equivalent if
they satisfy the following conditions:
1. Initial Read
An initial read of both schedules must be the same. Suppose
two schedule S1 and S2. In schedule S1, if a transaction T1 is
reading the data item A, then in S2, transaction T1 should
also read A.
Above two schedules are view equivalent because Initial read operation
in S1 is done by T1 and in S2 it is also done by T1.
2. Updated Read
In schedule S1, if Ti is reading A which is updated by Tj then in S2 also,
Ti should read A which is updated by Tj
Above two schedules are not view equal because, in S1, T3 is
reading A updated by T2 and in S2, T3 is reading A updated
by T1.
3. Final Write
A final write must be the same between both the schedules. In
schedule S1, if a transaction T1 updates A at last then in S2, final
writes operations should also be done by T1.
Above two schedules is view equal because Final
write operation in S1 is done by T3 and in S2, the
final write operation is also done by T3
Schedule S1
First step: Last update of the data items
No need of checking that condition as there isnā€™t any read in
s and S1 except initial read
Second step: Initial read
T1 does the initial read in S as well as S1
Third step: Final write
T3 does the final write task in S and S1. Therefore, S1 and S
are view equivalent.
S1 meets all the conditions, and so there is no need of
checking any other schedule.
Therefore, the view equivalent schedule is
T1-T2-T3
shadow-copy database scheme and db_pointer with an
example(Implementation of Atomicity and Durability).
ā€¢ This is the method where all the transactions are
executed in the primary memory or the shadow copy of
database. Once all the transactions completely
executed, it will be updated to the database.
ā€¢ Hence, if there is any failure in the middle of
transaction, it will not be reflected in the database.
ā€¢ Database will be updated after all the transaction is
complete
To understand concept, consider above figure. In this 2 write
operations are performed on page 3 and 5. Before start of
write operation on page 3, current page table points to old
page 3. When write operation starts following steps are
performed :
ā€¢ Firstly, search start for available free block in disk blocks.
ā€¢ After finding free block, it copies page 3 to free block
which is represented by Page 3 (New).
ā€¢ Now current page table points to Page 3 (New) on disk
but shadow page table points to old page 3 because it is
not modified.
ā€¢ The changes are now propagated to Page 3 (New) which is
pointed by current page table.
COMMIT Operation:
To commit transaction following steps should be done :
ā€¢ All the modifications which are done by transaction which
are present in buffers are transferred to physical
database.
ā€¢ Output current page table to disk.
ā€¢ Disk address of current page table output to fixed
location which is in stable storage containing address of
shadow page table. This operation overwrites address of
old shadow page table. With this current page table
becomes same as shadow page table and transaction is
committed.
ā€¢ A database pointer will be always pointing to the consistent copy of
the database, and copy of the database is used by transactions to
update. Once all the transactions are complete, the DB pointer is
modified to point to new copy of DB, and old copy is deleted.
ā€¢ If there is any failure during the transaction, the pointer will be still
pointing to old copy of database, and shadow database will be
deleted. If the transactions are complete then the pointer is changed
to point to shadow DB, and old DB is deleted.
ā€¢ DB pointer is always pointing to consistent and stable database. This
mechanism assumes that there will not be any disk failure and only
one transaction executing at a time so that the shadow DB can hold
the data for that transaction.
ā€¢ It is useful if the DB is comparatively small because shadow DB
consumes same memory space as the actual DB.
ā€¢ Hence it is not efficient for huge DBs. In addition, it cannot
handle concurrent execution of transactions. It is suitable for one
transaction at a time.
Advantages of concurrent execution of a transaction
Decrease waiting time or turnaround time.
Improve response time
Increased throughput or resource utilization.
Concurrency problems
Several problems can occur when concurrent transactions are
run in an uncontrolled manner, such type of problems is
known as concurrency problems.
1. Lost update problem (Write ā€“ Write conflict)
2. Dirty read problem (W-R conflict)
3. Unrepeatable read (R-W Conflict)
1. Lost update problem (Write ā€“ Write conflict)
This type of problem occurs when two transactions in database access
the same data item and have their operations in an interleaved
manner that makes the value of some database item incorrect.
If there are two transactions T1 and T2 accessing the same data item
value and then update it, then the second record overwrites the first
record.
ā€¢ Here,
ā€¢ At t1 time, T1 transaction reads the value of A i.e., 100.
ā€¢ At t2 time, T1 transaction deducts the value of A by 50.
ā€¢ At t3 time, T2 transactions read the value of A i.e., 100.
ā€¢ At t4 time, T2 transaction adds the value of A by 150.
ā€¢ At t5 time, T1 transaction writes the value of A data item
on the basis of value seen at time t2 i.e., 50.
ā€¢ At t6 time, T2 transaction writes the value of A based on
value seen at time t4 i.e., 150.
ā€¢ So at time T6, the update of Transaction T1 is lost
because Transaction T2 overwrites the value of A without
looking at its current value.
ā€¢ Such type of problem is known as the Lost Update
Problem
Dirty read problem (W-R conflict)
This type of problem occurs when one transaction T1
updates a data item of the database, and then that
transaction fails due to some reason, but its updates are
accessed by some other transaction.
Example: Let's take the value of A is 100
ā€¢ Here,
ā€¢ At t1 time, T1 transaction reads the value of A i.e., 100.
ā€¢ At t2 time, T1 transaction adds the value of A by 20.
ā€¢ At t3 time, T1transaction writes the value of A (120) in the
database.
ā€¢ At t4 time, T2 transactions read the value of A data item i.e., 120.
ā€¢ At t5 time, T2 transaction adds the value of A data item by 30.
ā€¢ At t6 time, T2transaction writes the value of A (150) in the
database.
ā€¢ At t7 time, a T1 transaction fails due to power failure then it is
rollback according to atomicity property of transaction (either all or
none).
ā€¢ So, transaction T2 at t4 time contains a value which has not been
committed in the database. The value read by the transaction T2 is
known as a dirty read.
Unrepeatable read (R-W Conflict)
It is also known as an inconsistent retrieval problem. If a transaction
T1 reads a value of data item twice and the data item is changed by
another transaction T2 in between the two read operation. Hence
T1 access two different values for its two read operation of the same
data item.
Example: Let's take the value of A is 100
ā€¢ At t1 time, T1 transaction reads the value of A i.e., 100.
ā€¢ At t2 time, T2transaction reads the value of A i.e., 100.
ā€¢ At t3 time, T2 transaction adds the value of A data item
by 30.
ā€¢ At t4 time, T2 transaction writes the value of A (130) in
the database.
ā€¢ Transaction T2 updates the value of A. Thus, when
another read statement is performed by transaction T1,
it accesses the new value of A, which was updated by T2.
Such type of conflict is known as R-W conflict.
Consider the following transactions with data items P and
Q initialized to zero:
T1: read(P);
read(Q);
If P=0 then Q:=Q+1;
write(Q);
T2: read(Q);
read(P);
If Q=0 then P:=P+1;
write(P);
Evaluate any non-serial interleaving of T1 and T2 for
concurrent execution leads to a serializable schedule or
non serializable schedule. Justify the answer?

More Related Content

Similar to MODULE 5.pptx

Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluationavniS
Ā 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql serverVinay Thota
Ā 
Sql server
Sql serverSql server
Sql serverPuja Gupta
Ā 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersAdam Hutson
Ā 
Python programming
Python programmingPython programming
Python programmingSwetha544947
Ā 
Ebook7
Ebook7Ebook7
Ebook7kaashiv1
Ā 
Sql interview question part 7
Sql interview question part 7Sql interview question part 7
Sql interview question part 7kaashiv1
Ā 
MOOC_PRESENTATION_FINAL_PART_1[1].pptx
MOOC_PRESENTATION_FINAL_PART_1[1].pptxMOOC_PRESENTATION_FINAL_PART_1[1].pptx
MOOC_PRESENTATION_FINAL_PART_1[1].pptxmh3473
Ā 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfNiravPanchal50
Ā 
Database testing
Database testingDatabase testing
Database testingPesara Swamy
Ā 
Ebook5
Ebook5Ebook5
Ebook5kaashiv1
Ā 
Sql interview question part 5
Sql interview question part 5Sql interview question part 5
Sql interview question part 5kaashiv1
Ā 
Sql Server
Sql ServerSql Server
Sql ServerSandyShin
Ā 
Sql interview question part 6
Sql interview question part 6Sql interview question part 6
Sql interview question part 6kaashiv1
Ā 
Ebook6
Ebook6Ebook6
Ebook6kaashiv1
Ā 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6kaashiv1
Ā 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6kaashiv1
Ā 
Ebook6
Ebook6Ebook6
Ebook6kaashiv1
Ā 

Similar to MODULE 5.pptx (20)

Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluation
Ā 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql server
Ā 
Chapter02
Chapter02Chapter02
Chapter02
Ā 
Sql server
Sql serverSql server
Sql server
Ā 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
Ā 
Python programming
Python programmingPython programming
Python programming
Ā 
Ebook7
Ebook7Ebook7
Ebook7
Ā 
Sql interview question part 7
Sql interview question part 7Sql interview question part 7
Sql interview question part 7
Ā 
MOOC_PRESENTATION_FINAL_PART_1[1].pptx
MOOC_PRESENTATION_FINAL_PART_1[1].pptxMOOC_PRESENTATION_FINAL_PART_1[1].pptx
MOOC_PRESENTATION_FINAL_PART_1[1].pptx
Ā 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdf
Ā 
Database testing
Database testingDatabase testing
Database testing
Ā 
Ebook5
Ebook5Ebook5
Ebook5
Ā 
Sql interview question part 5
Sql interview question part 5Sql interview question part 5
Sql interview question part 5
Ā 
Cassandra data modelling best practices
Cassandra data modelling best practicesCassandra data modelling best practices
Cassandra data modelling best practices
Ā 
Sql Server
Sql ServerSql Server
Sql Server
Ā 
Sql interview question part 6
Sql interview question part 6Sql interview question part 6
Sql interview question part 6
Ā 
Ebook6
Ebook6Ebook6
Ebook6
Ā 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
Ā 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
Ā 
Ebook6
Ebook6Ebook6
Ebook6
Ā 

More from lathass5

print mod 2.pdf
print mod 2.pdfprint mod 2.pdf
print mod 2.pdflathass5
Ā 
application_layer (1).pdf
application_layer (1).pdfapplication_layer (1).pdf
application_layer (1).pdflathass5
Ā 
EV List.pdf
EV List.pdfEV List.pdf
EV List.pdflathass5
Ā 
datalinklayermukesh-150130061041-conversion-gate01.pptx
datalinklayermukesh-150130061041-conversion-gate01.pptxdatalinklayermukesh-150130061041-conversion-gate01.pptx
datalinklayermukesh-150130061041-conversion-gate01.pptxlathass5
Ā 
Data and Signals.ppt
Data and Signals.pptData and Signals.ppt
Data and Signals.pptlathass5
Ā 
dtoa.ppt
dtoa.pptdtoa.ppt
dtoa.pptlathass5
Ā 
OOP PPT 1.pptx
OOP PPT 1.pptxOOP PPT 1.pptx
OOP PPT 1.pptxlathass5
Ā 

More from lathass5 (7)

print mod 2.pdf
print mod 2.pdfprint mod 2.pdf
print mod 2.pdf
Ā 
application_layer (1).pdf
application_layer (1).pdfapplication_layer (1).pdf
application_layer (1).pdf
Ā 
EV List.pdf
EV List.pdfEV List.pdf
EV List.pdf
Ā 
datalinklayermukesh-150130061041-conversion-gate01.pptx
datalinklayermukesh-150130061041-conversion-gate01.pptxdatalinklayermukesh-150130061041-conversion-gate01.pptx
datalinklayermukesh-150130061041-conversion-gate01.pptx
Ā 
Data and Signals.ppt
Data and Signals.pptData and Signals.ppt
Data and Signals.ppt
Ā 
dtoa.ppt
dtoa.pptdtoa.ppt
dtoa.ppt
Ā 
OOP PPT 1.pptx
OOP PPT 1.pptxOOP PPT 1.pptx
OOP PPT 1.pptx
Ā 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
Ā 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
Ā 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
Ā 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
Ā 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
Ā 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
Ā 
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
Ā 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
Ā 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
Ā 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
Ā 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
Ā 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
Ā 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
Ā 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
Ā 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
Ā 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
Ā 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Ā 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
Ā 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
Ā 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
Ā 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
Ā 
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
Ā 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
Ā 
Model Call Girl in Bikash Puri Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Bikash Puri  Delhi reach out to us at šŸ”9953056974šŸ”Model Call Girl in Bikash Puri  Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Bikash Puri Delhi reach out to us at šŸ”9953056974šŸ”
Ā 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
Ā 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
Ā 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
Ā 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
Ā 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
Ā 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
Ā 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
Ā 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
Ā 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
Ā 

MODULE 5.pptx

  • 2. TEXT BOOKS: 1. Abraham Silberschatz, Henry F. Korth, S. Sudharshan, ā€œDatabase System Conceptsā€, Sixth Edition, Tata McGraw Hill, 2013. 2. Ramez Elmasri, Shamkant B. Navathe, ā€œFundamentals of Database S y s t e m sā€ , Sixth Edition, Pearson / Addison - Wesley, 7th Edition 2017 REFERENCES: 1. Raghu Ramakrishnan, ā€œDatabase Management Systemsā€, Third Edition, McGraw Hill, 2013.
  • 3. MODULE 1-Introduction: Introduction, An example, Characteristics of Database Approach. Database Applications: Need for data management, Advantages of using DBMS approach. Data models & Database Architecture: Data models, schemas and instances, Three- schema architecture and data independence, Centralized and client- server architectures. MODULE 2-ER Diagrams: Entity Types, Entity Sets, Attributes and Keys, Relationship types, Roles and Structural Constraints, Weak Entity Types, ER Diagrams. MODULE 3-Relational Model: ER to Relational Mapping, Constraints, Keys Dependencies. Functional Dependencies: Normalization First, Second, Third & Fourth Normal Forms, BCNF.
  • 4. MODULE 4-Relational Algebra: Update Operations, Unary Relational Operations: SELECT and PROJECT, Relational Algebra Operations from Set Theory, Binary Relational Operations: JOIN and DIVISION; Additional Relational Operations; Examples of Queries in Relational Algebra; Relational Database Design Using ER- to-Relational Mapping. MODULE 5-Advanced SQL & Transaction Management : Embedded & Dynamic SQL , Stored procedures, More complex SQL Queries, Transaction concepts, Transaction state, Implementation of Atomicity & Durability, Concurrent executions, Seializability
  • 5. CO1 Understand the database concepts, different database models, and database management systems and design database schema CO2 Develop the ER structures for real world examples using the concept of Entity Relationship models with constraints and cardinalities. CO3 Understand the concepts of Normalization and design database which possess no anomalies. CO4 Apply the concepts of relational database theory to manage relational database management system. CO5 Apply the concepts of triggers, embedded and dynamic SQL. CO6 Implement database applications in SQL.
  • 6. Engineered for Tomorrow Advanced SQL & Transaction Management : Embedded & Dynamic SQL , Stored procedures, More complex SQL Queries, Transaction concepts, Transaction state, Implementation of Atomicity & Durability, Concurrent executions, Seializability
  • 8.
  • 9.
  • 10.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 19. Static (embedded) SQL: 1.In static SQL how database will be accessed is predetermined in the embedded SQL statement. 2.It is more swift and efficient. 3.SQL statements are compiled at compile time. 4.Parsing, validation, optimization, and generation of application plan are done at compile time. 5.It is generally used for situations where data is distributed uniformly. 6.EXECUTE IMMEDIATE, EXECUTE and PREPARE statements are not used.
  • 20. Dynamic (interactive) SQL: 1.In dynamic SQL, how database will be accessed is determined at run time. 2.It is less swift and efficient. 3.SQL statements are compiled at run time. 4.Parsing, validation, optimization, and generation of application plan are done at run time. 5.It is generally used for situations where data is distributed non- uniformly. 6.EXECUTE IMMEDIATE, EXECUTE and PREPARE statements are used. 7.It is more flexible.
  • 21. Database Stored Procedures and Functions ā€¢ The machine where the program is executing is different from the machine on which the database serverā€” and the main part of the DBMS software packageā€”is located. Although this is suitable for many applications, it is sometimes useful to create database program modulesā€”procedures or functionsā€” that are stored and executed by the DBMS at the database server. ā€¢ These are historically known as database stored procedures, although they can be functions or procedures. ā€¢ The term used in the SQL standard for stored procedures is persistent stored modules because these programs are stored persistently by the DBMS, similarly to the persistent data stored by the DBMS.
  • 22. Stored procedures are useful in the following circumstances: ā€¢ If a database program is needed by several applications, it can be stored at the server and invoked by any of the application programs. This reduces duplication of effort and improves software modularity. ā€¢ Executing a program at the server can reduce data transfer and communication cost between the client and server in certain situations. ā€¢ These procedures can enhance the modeling power provided by views by allowing more complex types of derived data to be made available to the database users. ā€¢ Additionally, they can be used to check for complex constraints that are beyond the specification power of assertions and triggers.
  • 23. In general, many commercial DBMSs allow stored procedures and functions to be written in a general purpose programming language. Alternatively, a stored procedure can be made of simple SQL commands such as retrievals and updates. The general form of declaring stored procedures is as follows: The parameters and local declarations are optional, and are specified only if needed. For declaring a function, a return type is necessary, so the declaration form is
  • 24. If the procedure (or function) is written in a general-purpose programming language, it is typical to specify the language as well as a file name where the program code is stored. For example, the following format can be used: ā€¢ In general, each parameter should have a parameter type that is one of the SQL data types. Each parameter should also have a parameter mode, which is one of IN, OUT, or INOUT. ā€¢ These correspond to parameters whose values are input only, output (returned) only, or both input and output, respectively. ā€¢ Because the procedures and functions are stored persistently by the DBMS, it should be possible to call them from the various SQL interfaces and programming techniques. ā€¢ The CALL statement in the SQL standard can be used to invoke a stored procedureā€”either from an interactive interface or from embedded SQL or SQLJ. ā€¢ The format of the statement is as follows:
  • 25. Transaction States A transaction is a unit of program execution that accesses and possibly updates various data items.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. Seializability Serializable Schedule A serial schedule is always a serializable schedule because any transaction only starts its execution when another transaction has already completed its execution. However, a non-serial schedule of transactions needs to be checked for Serializability. Note: If a schedule of concurrent ā€˜n' transactions can be converted into an equivalent serial schedule. Then we can say that the schedule is serializable. And this property is known as serializability.
  • 34. Testing of Serializability To test the serializability of a schedule, we can use the serialization graph. Suppose, a schedule S. For schedule S, construct a graph called as a precedence graph. It has a pair G = (V, E), where E consists of a set of edges, and V consists of a set of vertices. The set of vertices contain all the transactions participating in the S schedule. The set of edges contains all edges Ti ->Tj for which one of the following three conditions satisfy: Create a node Ti -> Tj if Ti transaction executes write (Q) before Tj transaction executes read (Q). Create a node Ti -> Tj if Ti transaction executes read (Q) before Tj transaction executes write (Q). Create a node Ti -> Tj if Ti transaction executes write (Q) before Tj transaction executes write (Q).
  • 36. If a precedence graph for any schedule contains a cycle, then that schedule is non-serializable. If the precedence graph has no cycle, then the schedule is serializable. So, schedule S is serializable (i.e., serial schedule) because the precedence graph has no cycle
  • 37. Precedence graph of Schedule S1
  • 38.
  • 39.
  • 40. Types of Serializability Conflict Serializability View Serializability
  • 41. Conflicting operations The two operations are called conflicting operations, if all the following three conditions are satisfied: Both the operation belongs to separate transactions. Both works on the same data item. At least one of them contains one write operation. Note: Conflict pairs for the same data item are: Read-Write Write-Write Write-Read Conflict Equivalent Schedule Two schedules are called as a conflict equivalent schedule if one schedule can be transformed into another schedule by swapping non-conflicting operations.
  • 42. Example of conflict serializability:
  • 43. After all the steps, the precedence graph will be ready, and it does not contain any cycle or loop, so the above schedule S2 is conflict serializable. And it is equivalent to a serial schedule.
  • 44. PL/SQL - Basic Syntax PL/SQL which is a block-structured language; this means that the PL/SQL programs are divided and written in logical blocks of code. Each block consists of three sub-parts āˆ’
  • 45. Every PL/SQL statement ends with a semicolon (;). PL/SQL blocks can be nested within other PL/SQL blocks using BEGIN and END. Following is the basic structure of a PL/SQL block āˆ’
  • 46. 1 2 3 4 5 6 7 8 9 10 11 Declare Var1 integer; Var2 integer; Var3 integer; Begin Var1:=&var1; Var2:=&var2; Var3:=var1+var2; Dbms_output.put_line(var3); End; / PL/SQL Program To Add Two Numbers
  • 47. View Serializability In DBMS ā€¢ If a schedule is view equivalent to a serial schedule, then it will be view serializable ā€¢ If the schedule is serializable via conflict, then it shall be view serializable as well. ā€¢ The view serializable which has no conflict serializable has blind writes. View Equivalent Schedules S1 and schedule S2 will; be view equivalent if the following conditions are satisfied:
  • 48. View Equivalent Two schedules S1 and S2 are said to be view equivalent if they satisfy the following conditions: 1. Initial Read An initial read of both schedules must be the same. Suppose two schedule S1 and S2. In schedule S1, if a transaction T1 is reading the data item A, then in S2, transaction T1 should also read A. Above two schedules are view equivalent because Initial read operation in S1 is done by T1 and in S2 it is also done by T1.
  • 49. 2. Updated Read In schedule S1, if Ti is reading A which is updated by Tj then in S2 also, Ti should read A which is updated by Tj Above two schedules are not view equal because, in S1, T3 is reading A updated by T2 and in S2, T3 is reading A updated by T1.
  • 50. 3. Final Write A final write must be the same between both the schedules. In schedule S1, if a transaction T1 updates A at last then in S2, final writes operations should also be done by T1. Above two schedules is view equal because Final write operation in S1 is done by T3 and in S2, the final write operation is also done by T3
  • 51.
  • 52. Schedule S1 First step: Last update of the data items No need of checking that condition as there isnā€™t any read in s and S1 except initial read Second step: Initial read T1 does the initial read in S as well as S1 Third step: Final write T3 does the final write task in S and S1. Therefore, S1 and S are view equivalent. S1 meets all the conditions, and so there is no need of checking any other schedule. Therefore, the view equivalent schedule is T1-T2-T3
  • 53. shadow-copy database scheme and db_pointer with an example(Implementation of Atomicity and Durability). ā€¢ This is the method where all the transactions are executed in the primary memory or the shadow copy of database. Once all the transactions completely executed, it will be updated to the database. ā€¢ Hence, if there is any failure in the middle of transaction, it will not be reflected in the database. ā€¢ Database will be updated after all the transaction is complete
  • 54.
  • 55.
  • 56. To understand concept, consider above figure. In this 2 write operations are performed on page 3 and 5. Before start of write operation on page 3, current page table points to old page 3. When write operation starts following steps are performed : ā€¢ Firstly, search start for available free block in disk blocks. ā€¢ After finding free block, it copies page 3 to free block which is represented by Page 3 (New). ā€¢ Now current page table points to Page 3 (New) on disk but shadow page table points to old page 3 because it is not modified. ā€¢ The changes are now propagated to Page 3 (New) which is pointed by current page table.
  • 57. COMMIT Operation: To commit transaction following steps should be done : ā€¢ All the modifications which are done by transaction which are present in buffers are transferred to physical database. ā€¢ Output current page table to disk. ā€¢ Disk address of current page table output to fixed location which is in stable storage containing address of shadow page table. This operation overwrites address of old shadow page table. With this current page table becomes same as shadow page table and transaction is committed.
  • 58. ā€¢ A database pointer will be always pointing to the consistent copy of the database, and copy of the database is used by transactions to update. Once all the transactions are complete, the DB pointer is modified to point to new copy of DB, and old copy is deleted. ā€¢ If there is any failure during the transaction, the pointer will be still pointing to old copy of database, and shadow database will be deleted. If the transactions are complete then the pointer is changed to point to shadow DB, and old DB is deleted. ā€¢ DB pointer is always pointing to consistent and stable database. This mechanism assumes that there will not be any disk failure and only one transaction executing at a time so that the shadow DB can hold the data for that transaction. ā€¢ It is useful if the DB is comparatively small because shadow DB consumes same memory space as the actual DB. ā€¢ Hence it is not efficient for huge DBs. In addition, it cannot handle concurrent execution of transactions. It is suitable for one transaction at a time.
  • 59.
  • 60. Advantages of concurrent execution of a transaction Decrease waiting time or turnaround time. Improve response time Increased throughput or resource utilization. Concurrency problems Several problems can occur when concurrent transactions are run in an uncontrolled manner, such type of problems is known as concurrency problems. 1. Lost update problem (Write ā€“ Write conflict) 2. Dirty read problem (W-R conflict) 3. Unrepeatable read (R-W Conflict)
  • 61. 1. Lost update problem (Write ā€“ Write conflict) This type of problem occurs when two transactions in database access the same data item and have their operations in an interleaved manner that makes the value of some database item incorrect. If there are two transactions T1 and T2 accessing the same data item value and then update it, then the second record overwrites the first record.
  • 62. ā€¢ Here, ā€¢ At t1 time, T1 transaction reads the value of A i.e., 100. ā€¢ At t2 time, T1 transaction deducts the value of A by 50. ā€¢ At t3 time, T2 transactions read the value of A i.e., 100. ā€¢ At t4 time, T2 transaction adds the value of A by 150. ā€¢ At t5 time, T1 transaction writes the value of A data item on the basis of value seen at time t2 i.e., 50. ā€¢ At t6 time, T2 transaction writes the value of A based on value seen at time t4 i.e., 150. ā€¢ So at time T6, the update of Transaction T1 is lost because Transaction T2 overwrites the value of A without looking at its current value. ā€¢ Such type of problem is known as the Lost Update Problem
  • 63. Dirty read problem (W-R conflict) This type of problem occurs when one transaction T1 updates a data item of the database, and then that transaction fails due to some reason, but its updates are accessed by some other transaction. Example: Let's take the value of A is 100
  • 64. ā€¢ Here, ā€¢ At t1 time, T1 transaction reads the value of A i.e., 100. ā€¢ At t2 time, T1 transaction adds the value of A by 20. ā€¢ At t3 time, T1transaction writes the value of A (120) in the database. ā€¢ At t4 time, T2 transactions read the value of A data item i.e., 120. ā€¢ At t5 time, T2 transaction adds the value of A data item by 30. ā€¢ At t6 time, T2transaction writes the value of A (150) in the database. ā€¢ At t7 time, a T1 transaction fails due to power failure then it is rollback according to atomicity property of transaction (either all or none). ā€¢ So, transaction T2 at t4 time contains a value which has not been committed in the database. The value read by the transaction T2 is known as a dirty read.
  • 65. Unrepeatable read (R-W Conflict) It is also known as an inconsistent retrieval problem. If a transaction T1 reads a value of data item twice and the data item is changed by another transaction T2 in between the two read operation. Hence T1 access two different values for its two read operation of the same data item. Example: Let's take the value of A is 100
  • 66. ā€¢ At t1 time, T1 transaction reads the value of A i.e., 100. ā€¢ At t2 time, T2transaction reads the value of A i.e., 100. ā€¢ At t3 time, T2 transaction adds the value of A data item by 30. ā€¢ At t4 time, T2 transaction writes the value of A (130) in the database. ā€¢ Transaction T2 updates the value of A. Thus, when another read statement is performed by transaction T1, it accesses the new value of A, which was updated by T2. Such type of conflict is known as R-W conflict.
  • 67. Consider the following transactions with data items P and Q initialized to zero: T1: read(P); read(Q); If P=0 then Q:=Q+1; write(Q); T2: read(Q); read(P); If Q=0 then P:=P+1; write(P); Evaluate any non-serial interleaving of T1 and T2 for concurrent execution leads to a serializable schedule or non serializable schedule. Justify the answer?