DBMS Question Bank and Solutions
DBMS Question Bank and Solutions
DBMS Question Bank and Solutions
iii) Meta-data
The DDL compiler processes schema definitions, specified in the DDL, and stores
descriptions of the schemas (meta-data) in the DBMS catalog. The catalog includes
information such as the names and sizes of files, names and data types of data items,
storage details of each file, mapping information among schemas, and constraints.
or
The DBMS stores the descriptions of the schema constructs and constraints—also
called the meta-data—in the DBMS catalog so that DBMS software can refer to the
schema whenever it needs to. The schema is sometimes called the intension.
or
The complete definition or description of the database structure and constraints. This
definition is stored in the DBMS catalog, which contains information such as the
structure of each file, the type and storage format of each data item, and various
constraints on the data. The information stored in the catalog is called meta-data
o Design of the conceptual and physical schemas: The DBA is responsible for
interacting with the users of the system to understand what data is to be stored in
the DBMS and how it is likely to be used. The DBA creates the original schema
by writing a set of definitions and is Permanently stored in the 'Data Dictionary'.
o Security and Authorization: The DBA is responsible for ensuring the
unauthorized data access is not permitted. The granting of different types of
authorization allows the DBA to regulate which parts of the database various
users can access.
o Storage structure and Access method definition: The DBA creates appropriate
storage structures and access methods by writing a set of definitions, which are
translated by the DDL compiler.
o Data Availability and Recovery from Failures: The DBA must take steps to
ensure that if the system fails, users can continue to access as much of the
uncorrupted data as possible. The DBA also work to restore the data to consistent
state.
o Database Tuning: The DBA is responsible for modifying the database to ensure
adequate Performance as requirements change.
o Integrity Constraint Specification: The integrity constraints are kept in a special
system structure that is consulted by the DBA whenever an update takes place in
the system.
v) Data independence
Logical data independence is the capacity to change the conceptual schema without having to
change external schemas or application programs. We may change the conceptual schema to
expand the database (by adding a record type or data item), to change constraints, or to
reduce the database
Physical data independence is the capacity to change the internal schema without having to
change the conceptual schema. Hence, the external schemas need not be changed as well.
3. Construct an E-R diagram for a hospital database with a set of patients and a set of medical
doctors. Associate with each patient a log of the various tests and examinations conducted. The
patient has a history of Medicine purchased for their treatment based on prescription, and also
specify price for those medicines. Identify the relation among the schemas and represent the
cardinality ratio. 10 marks
Schemas
Relationships
1. Patient is consulted by Doctor
2. Doctor performs the test
3. Patient has test records
4. Test generated the bill
5. Bill paid by patient
Date-Admitted
pname
Date-check out
pid
Patient
consults
Pay by
Test log
Bill Doctor
bno
Performed
Generates by
amount
dname
Discount did
test Specialization
tid
tname time
date result
Cardinality ratio
i) Retrieve names of sailors who have reserved a red and a green boat.
T1←Π(sanme) (σ(color=”red”)((sailors* reserves)* boats)
T2←Π(sanme) (σ(color=”green”)((sailors* reserves)* boats)
T3←T1UT2
ii) Retrieve sid and names of sailors with age more than 20, who have not Reserved a
Red boat.
T1←Π(sid,sanme) (σ(color≠”red” and age>20)((sailors* reserves)* boats)
iii) Retrieve the boat names which are not reserved by any Sailors.
T1←Π(banme)( boats)
T2←Π(banme) (reserves* boats)
T3←T1-T2
iv) Retrieve the sailor names who have reserved yellow boat on Sunday.
T1←Π(sanme) (σ(color=”yellow” and day=”Sunday”)((sailors* reserves)* boats)
v) Retrieve the boat names which has reserved by highest rating sailors.
T1←Π(banme)( σ(rating=(F max(rating) Sailors) ((sailors* reserves)* boats)
Note that the Employees relation describes pilots and other kinds of employees as well; every pilot
is certified for some aircraft (otherwise, he or she would not qualify as a pilot), and only pilots are
certified to fly. 10 marks
i. Find the eids and employee names of pilots certified for some Boeing aircraft.
Select eid,ename from aircraft a,certified c, employees e where a.aid=c.aid and
c.eid=e.eid and aname=”Boeing”
ii. Find the aids and aircraft names that can be used on non-stop flights from Bangalore to
Madras.
iii. Identify the flights that can be piloted by every pilot whose salary is more than ₹100,000.
Select aid, aname from aircraft where aid in (select aid from certified where eid in( Select
eid from employee where salary>100000))
iv. Find the names of pilots who can operate planes with a range greater than 3,000 miles but
are not certified on any Boeing aircraft.
Select eid,ename from employee e, certified c where e.eid= c.eid and c.acid in (Select aid
from aircraft where crusingrange>3000 and aname!=”Boeing”)
v. Find the eids and names of employees who are certified for the largest number of aircraft.
Create view maxcer as (select eid,count(*) as acount from certified group by(eid))
Slect eid,name from employee where eid in(select eid from certified where from certified group
by (eid) having coun(*)=select from max(account) from maxcer)
6. Draw the DBMS component module diagram; explain their interactions with every module.
10 marks
Users
DDL compiler
Query compiler
Stored data manger
Runtime processor
System catalog
7. Explain the select, project and rename operations in relational algebra with suitable example.
10 marks
Selection Operator(σ)
Selection and Projection are unary operators.
The selection operator is sigma: σ
The selection operation acts like a filter on a relation by returning only a certain number of
tuples.
σC(R) Returns only those tuples in R that satisfy condition C
A condition C can be made up of any combination of comparison or logical operators that
operate on the attributes of R. Comparison operators: >,<,<=,>=, ≠,==
Logical operators
┐- not, v - or
Example
Select only those Employees in the CS department:
σ Dept= 'CS'(EMP)
Projection(π)
Notation − ρ x (E)
SQL Constraints
SQL constraints are used to specify rules for the data in a table.
Constraints are used to limit the type of data that can go into a table. This ensures the accuracy
and reliability of the data in the table. If there is any violation between the constraint and the data
action, the action is aborted.
Constraints can be column level or table level. Column level constraints apply to a column, and
table level constraints apply to the whole table.
ODBC and JDBC, short for Open Database Connectivity and Java Database Connectivity, also
enable the integration of SQL with a general-purpose programming language. Both ODBC and
JDBC expose database capabilities in a standardized way to the application programmer through
an application programming interface (API). In contrast to Embedded SQL, ODBC and JDBC
allow a single executable to access different DBMSs Without recompilation.
The architecture of JDBC has four main components: the application, the driver manager, several
data source specific drivers, and the corresponding data SOUTces.
JDBC Driver Management
The following Java example code explicitly loads a JDBC driver:
Class.forName("oracle/jdbc.driver.OracleDriver");
There are two other ways of registering a driver. We can include the driver with -
jdbc.drivers=oracle/jdbc.driver at the command line when we start the Java application.
Connections
A session with a data source is started through creation of a Connection object; A connection
identifies a logical session with a data source; multiple connections within the same Java
program can refer to different data sources or the same data source. Connections are specified
through a JDBC URL, a URL that uses the jdbc protocol. Such a URL has the form
jdbc:<subprotocol>:<otherParameters>
String uri = ..jdbc:oracle:www.bookstore.com:3083..
Connection connection;
try {
Connection connection = DriverManager.getConnection(urI,userId,password);
} catch(SQLException excpt)
{ System.out.println(excpt.getMessageO);
return;
}
ResultSets
The statement executeQuery returns a, ResultSet object, which is similar to a cursor.
ResultSet rs=stmt.executeQuery(sqlQuery); / / rs is now a cursor / / first call to rs.nextO moves
to the first record / /
rs.nextO moves to the next row String sqlQuery;
ResultSet rs = stmt.executeQuery(sqlQuery)
while (rs.next())
{ / / process the data }
Using a ResultSet Object While next () allows us to retrieve the logically next row in the query
answer, we can move about in the query answer in other ways too:
• previous moves back one row.
• absolute (int num) moves to the row with the specified number.
• relative(int num) moves forward or backward (if num is negative) relative to the current
position.
relative(-1) has the same effect as previous.
• first 0 moves to the first row, and last0 moves to the last row.
10. Define SQLJ. Explain the Process of declaring the SQLJ objects and write the SQLJ
code for displaying the data from the table named STUDENT.
SQLJ (short for 'SQL-Java') was developed by the SQLJ Group, a group of database vendors
and Sun. SQLJ was developed to complement the dynamic way of creating queries in JDBC
with a static model. It is therefore very close to Embedded SQL.
Unlike JDBC, having semi-static SQL queries allows the compiler to perform SQL syntax
checks, strong type checks of the compatibility of the host variables with the respective SQL
attributes, and consistency of the query with the database schema-tables, attributes, views, and
stored procedures--all at compilation time.
#sql books = { SELECT usn, name INTO :rollno, :sname FROM student WHERE phone=
:mobile };
In JDBC, we can dynamically decide which host language variables will hold the query result.
In the following example, we read the title of the book into variable ftitle if the book was
written by Feynman, and into variable otitle otherwise:
/ / assume we have a ResultSet cursor rs author = rs.getString(3);
if (name==”kumar")
{
sname = rs.getString(2):
}
else
{
lname = rs.getString(2);
}
SQLJ Code
String sname,lname, phone;
#sql iterator STUDENTS (String sname, String phone);
STUDENTS students;
/ / the application sets the author
/ / execute the query and open the cursor
#sql students = { SELECT sname, phone INTO :sname, :phone FROM Students WHERE
sname= :sname };
/ / retrieve results
while (students.next())
{
System.out.println(students.sname ()+ ", " + students.phone()); }
students.close();
The corresponding JDBC code fragment looks as follows (assuming we also declared phone,
aname, and lname:
The application logic will be implemented in Java, and so they consider JDBC and SQLJ as
possible candidates for interfacing the database system with application code.
Recall that Database settled on the following schema:
Books(isbn: CHAR(10), title: CHAR(8), author: CHAR(80), qty_in_stock: INTEGER, price:
REAL, year_published: INTEGER)
Customers(cid: INTEGER, cname: CHAR(80), address: CHAR(200))
Orders(ordernum: INTEGER, isbn: CHAR(lO), cid: INTEGER, cardnum: CHAR(l6), qty:
INTEGER, order_date: DATE, ship_date: DATE)
Now, Database considers the types of queries and updates that will arise. They first create a list
of tasks that will be performed in the application. Tasks performed by customers include the
following.
• Customers search books by author name, title, or ISBN.
• Customers register with the website. Registered customers might want to change their
contact information. Database realize that they have to augment the Customers table with
additional information to capture login and password information for each customer; we do
not discuss this aspect any further.
• Customers check out a final shopping basket to complete a sale.
• Customers add and delete books from a 'shopping basket' at the website.
• Customers check the status of existing orders and look at old orders.
• Administrative ta.'3ks performed by employees of B&N are listed next.
• Employees look up customer contact information.
• Employees add new books to the inventory.
• Employees fulfill orders, and need to update the shipping date of individual books.
• Employees analyze the data to find profitable customers and customers likely to respond to
special marketing campaigns.
Next database consider the types of queries that will arise out of these tasks. To support
searching for books by name, author, title, or ISBN, database decide to write a stored procedure
as follows:
Database Application Development
CREATE PROCEDURE SearchByISBN (IN book.isbn CHAR (10) ) SELECT B.title,
B.author, B.qty_instock,B.price, B.yearpublished FROM Books B WHERE B.isbn = book.isbn
Placing an order involves inserting one or more records into the Orders table. Since Database
has not yet chosen the Java-based technology to program the application logic, they assume for
now that the individual books in the order are stored at the application layer in a Java array. To
finalize the order, they write the following JDBC code shown in Figure 6.11, which inserts the
elements from the array into the Orders table. Note that this code fragment assumes several Java
variables have been set beforehand.
String sql = "INSERT INTO Orders VALUES(?, ?, ?, ?, ?, ?)";
PreparedStatement pstmt = con.prepareStatement(sql);
con.setAutoCommit(false);
try {
/ / orderList is a vector of Order objects
/ / ordernum is the current order number
/ / dd is the ID of the customer, cardnum is the credit card number
for (int i=0; iiorderList.length(); i++)
Single-tier architectures have a,n important drawback: Users expect graphical interfaces that
require much more computational power than simple dumb terminals. Centralized computation
of the graphical displays of such interfaces requires much more computational power than a
single server have available, and thus single-tier architectures do not scale to thousands of users.
The commoditization of the PC and the availability of cheap client computers led to the
development of the two-tier architecture
Single Tier
Two Tier
• Presentation Tier: Users require a natural interface to make requests, provide input, and to
see results. The widespread use of the Internet has made Web-based interfaces increasingly
popular.
• Middle Tier: The application logic executes here. An enterprise-class application reflects
complex business processes, and is coded in a general purpose language such as C++ or
Java.
• Data Management Tier: Data-intensive Web applications involve DBMSs, which are the
subject of this book.
At the presentation layer, we need to provide forms through which the user can issue requests,
and display responses that the middle tier generates.
The middle layer runs code that implements the business logic of the application: It controls what
data needs to be input before an action can be executed, determines the control flow between
multi-action steps, controls access to the database layer, and often assembles dynamically
generated HTML pages from database query results.
13. List of Client tier technologies used in presentation Layer. Describe with suitable
Example.
HTML Forms
HTML forms are a common way of communicating data from the client tier to the middle tier.
The general format of a form is the following:
<FORM ACTION="page.jsp" METHOD="GET" NAME="LoginForm">
</FORM>
A single HTML document can contain more than one form. Inside an HTML form, we can have
any HTML tags except another FORM element.
The FORM tag has three important attributes:
• ACTION: Specifies the URI of the page to which the form contents are submitted; if the
ACTION attribute is absent, then the URI of the current page is used. In the sample
above, the form input would be submitted to the page named page. j sp, which should
provide logic for processing the input from the form
• METHOD: The HTTP/1.0 method used to submit the user input from the filled-out form
to the web server. There are two choices, GET and POST; we postpone their discussion
to the next section.
• NAME: This attribute gives the form a name. Although not necessary, naming forms is
good style. The client-side programs in JavaScript that refer to forms by name and
perform checks on form fields.
Inside HTML forms, the INPUT, SELECT, and TEXTAREA tags are used to specify user input
elements; a form can have many elements of each type. The simplest user input element is an
INPUT field, a standalone tag with no terminating tag. An example of an INPUT tag is the
following:
<INPUT TYPE=”text" NAME="title">
JavaScript
JavaScript is often used for the following types of computation at the client:
• Browser Detection: JavaScript can be used to detect the browser type and load a browser-
specific page.
• Form Validation: JavaScript is used to perform simple consistency checks on form fields.
For example, a JavaScript program might check whether form input that asks for an email
address contains the character '@,' or if all required fields have been input by the user.
• Browser Control: This includes opening pages in customized windows; examples include
the annoying pop-up advertisements that you see at many websites, which are
programmed using JavaScript.
JavaScript is usually embedded into an HTML document with a special tag, the SCRIPT tag.
<SCRIPT LANGUAGE=" JavaScript">
alert(" Welcome to our bookstore");
</SCRIPT
Style Sheets
BODY {BACKGROUND-COLOR: yellow}
H1 {FONT-SIZE: 36pt}
H3 {COLOR: blue}
P {MARGIN-LEFT: 50px; COLOR: red}
The use of style sheets has many advantages. First, we can reuse the same document many times
and display it differently depending on the context. Second, we can tailor the display to the
reader's preference such as font size, color style, and even level of detail. Third, we can deal with
different output formats, such as different output devices.
14. Explain the informal guidelines used as a measures to determine the quality of relation
schema design.
15. Define Normal Form. Explain 1NF, 2NF, 3NF and Boyce Codd Normal Forms with
suitable Example.
• Normalization: The process of decomposing unsatisfactory "bad" relations by
breaking up their attributes into smaller relations
• Normal form: Condition using keys and FDs of a relation to certify whether a relation
schema is in a particular normal form
– A superkey of a relation schema R = {A1, A2, ...., An} is a set of attributes S subset-
of R with the property that no two tuples t1 and t2 in any legal relation state r of R
will have t1[S] = t2[S]
– A key K is a superkey with the additional property that removal of any attribute
from K will cause K not to be a superkey any more.
First Normal Form
Disallows composite attributes, multivalued attributes, and nested relations; attributes
whose values for an individual tuple are non-atomic
Second Normal Form
– Uses the concepts of FDs, primary key
Definitions:
– Prime attribute - attribute that is member of the primary key K
– Full functional dependency - a FD Y -> Z where removal of any attribute from Y
means the FD does not hold any more
– A relation schema R is in second normal form (2NF) if every non-prime attribute A
in R is fully functionally dependent on the primary key
– R can be decomposed into 2NF relations via the process of 2NF normalization
BCNF
– A relation schema R is in Boyce-Codd Normal Form (BCNF) if whenever an FD X
-> A holds in R, then X is a superkey of R
– Each normal form is strictly stronger than the previous one
Every 2NF relation is in 1NF
Every 3NF relation is in 2NF
Every BCNF relation is in 3NF
– There exist relations that are in 3NF but not in BCNF
– The goal is to have each relation in BCNF (or 3NF)
16. Write the Short Note on
i)Triggers
Objective: to monitor a database and take action when a condition occurs
Triggers are expressed in a syntax similar to assertions and include the following:
– event (e.g., an update operation)
– condition
– action (to be taken when the condition is satisfied)
A trigger to compare an employee’s salary to his/her supervisor during insert or update
operations:
CREATE TRIGGER INFORM_SUPERVISOR
BEFORE INSERT OR UPDATE OF
SALARY, SUPERVISOR_SSN ON EMPLOYEE
FOR EACH ROW
WHEN
(NEW.SALARY> (SELECT SALARY FROM EMPLOYEE
WHERE SSN=NEW.SUPERVISOR_SSN))
INFORM_SUPERVISOR (NEW.SUPERVISOR_SSN,NEW.SSN;
ii)Stored Procedures
Stored procedures are also beneficial for software engineering reasons. Once a stored procedure
is registered with the database server, different users can re-use the stored procedure, eliminating
duplication of efforts in writing SQL queries or application logic, and making code maintenance
easily
Allows the user to specify different types of joins (regular "theta" JOIN, NATURAL JOIN,
LEFT OUTER JOIN, RIGHT OUTER JOIN, CROSS JOIN, etc)
SELECT E.FNAME, E.LNAME, S.FNAME, S.LNAME
FROM EMPLOYEE E S
WHERE E.SUPERSSN=S.SSN
can be written as:
v) Views
• A view is a “virtual” table that is derived from other tables
• Allows for limited update operations (since the table may not physically be stored)
• Allows full query operations
• A convenience for expressing certain operations
• SQL command: CREATE VIEW
a table (view) name
a possible list of attribute names (for example, when arithmetic operations are
specified or when we want the names to be different from the attributes in the
base relations)
a query to specify the table contents
CREATE View WORKS_ON_NEW AS
SELECT FNAME, LNAME, PNAME, HOURS
FROM EMPLOYEE, PROJECT, WORKS_ON
WHERE SSN=ESSN AND PNO=PNUMBER
GROUP BY PNAME;
b) What is Concurrency? Explain the types of problem during occurs due concurrency.
DBMS has a Concurrency Control sub-system to assure database remains in consistent state
despite concurrent execution of transactions
18. Define lock. Write and explain the algorithm to control the concurrency using Two-Phase
Locking Protocol.
Lock
• A variable associated with a data item
• Describes status of the data item with respect to operations that can be performed
on it
Types of locks
• Binary locks
• Locked/unlocked
• Enforces mutual exclusion
Multiple-mode locks:
• Each data item can be in one of three lock states
1. Read lock or shared lock
2. Write lock or exclusive lock
3. Unlock
2PL Example
• Both T1’ and T2’ follow the 2PL protocol
• Any schedule including T1’ and T2’ is guaranteed to be serializable
• Limits the amount of concurrency
• Two-phase locking protocol (2PL)
All lock operations precede the first unlock operation
• Expanding phase and shrinking phase
• Upgrading of locks must be done in expanding phase and downgrading of locks
must be done in shrinking phase
• If every transaction in a schedule follows 2PL protocol then the schedules is guaranteed
to be serializable.
• Variants of 2PL
Basic, conservative, strict, and rigorous
19 a) List the transaction states. Draw and explain state transition diagram of the transaction.
Transaction states
• BEGIN_TRANSACTION: marks start of transaction
• READ or WRITE: two possible operations on the data
• END_TRANSACTION: marks the end of the read or write operations; start checking
whether everything went according to plan
• COMIT_TRANSACTION: signals successful end of transaction; changes can be
“committed” to DB
• Partially committed
• ROLLBACK (or ABORT): signals unsuccessful end of transaction, changes applied to
DB must be undone
b) Describe the list of steps include during the transaction read and write operations
• A database is represented as a collection of named data items
• Read-item (X)
1. Find the address of the disk block that contains item X
2. Copy the disk block into a buffer in main memory
3. Copy the item X from the buffer to the program variable named X
• Write-item (X)
1. Find the address of the disk block that contains item X.
2. Copy that disk block into a buffer in main memory
3. Copy item X from the program variable named X into its correct location in the
buffer.
4. Store the updated block from the buffer back to disk (either immediately or at
some later point in time).
.
20. When the deadlock and Starvation occurs? Explain these problems can resolved.
21. How to recover the transaction from failure? Explain the list of recovery concepts.
• Keeps information about operations made by transactions:
– Before-image (undo entry) of updated items
– After-image (redo entry) of updated items
• Enables restoring a consistent state after non-catastrophic failure (forward/backward).
• Alternatives:
– undo/no-redo
– no-undo/redo
– undo/redo
– no-undo/no-redo.
Write-Ahead Logging (WAL)
Backup
• Copy of database on archival storage
(off-line, often on tape).
• Enables partial recovery from catastrophic failures:
– For committed transactions:
Load backup and apply redo operations from the
log (if the log survived).
– Non-committed transactions must be restarted
(= re-executed).
Cache
c)The relation SUPPLY with no MVDs is in 4NF but not in 5NF if it has the JD(R1, R2, R3). (d)
Decomposing the relation SUPPLY into the 5NF relations R1, R2, and R3
For a table to satisfy the Fourth Normal Form, it should satisfy the following two conditions:
A multivalued dependency (MVD) X —>> Y specified on relation schema R, where X
and Y are both subsets of R, specifies the following constraint on any relation state r of R:
If two tuples t1 and t2 exist in r such that t1[X] = t2[X], then two tuples t3 and t4 should
also exist in r with the following properties, where we use Z to denote (R 2 (X υ Y)):
· t3[X] = t4[X] = t1[X] = t2[X].
· t3[Y] = t1[Y] and t4[Y] = t2[Y].
· t3[Z] = t2[Z] and t4[Z] = t1[Z].
An MVD X —>> Y in R is called a trivial MVD if (a) Y is a subset of X, or (b) X υ Y = R.
1 Science Cricket
1 Maths Hockey
2 C# Cricket
2 Php Hockey
1. As you can see in the table above, student with s_id 1 has opted for two
courses, Science and Maths, and has two hobbies, Cricket and Hockey.
A relation schema R is in fifth normal form (5NF) (or Project-Join Normal Form (PJNF))
with respect to a set F of functional, multivalued, and join dependencies if, for every nontrivial
join dependency JD(R1, R2, ..., Rn) in F+ (that is, implied by F), every Ri is a superkey of R.
o In the above table, John takes both Computer and Math class for Semester 1 but he
doesn't take Math class for Semester 2. In this case, combination of all these fields
required to identify a valid data.
o Suppose we add a new Semester as Semester 3 but do not know about the subject and
who will be taking that subject so we leave Lecturer and Subject as NULL. But all three
columns together acts as a primary key, so we can't leave other two columns blank.
o So to make the above table into 5NF, we can decompose it into three relations P1, P2 &
P3:
Lossless Decomposition
o If the information is not lost from the relation that is decomposed, then the decomposition
will be lossless.
o The lossless decomposition guarantees that the join of relations will result in the same
relation as it was decomposed.
o The relation is said to be lossless decomposition if natural joins of all the decomposition
give the original relation.
ii)Template Dependency
Template dependencies provide a technique for representing constraints in relations that
typically have no easy and formal definitions.
The idea is to specify a template—or example—that defines each constraint or
dependency.
There are two types of templates: tuple-generating templates and constraint-generating
templates.
A template consists of a number of hypothesis tuples that are meant to show an example of the
tuples that may appear in one or more relations. The other part of the template is the template
conclusion.
To formalize two types of interrelational constraints which cannot be expressed using F.D.s or
MVDs:
Referential integrity constraints
Class/subclass relationships
Inclusion dependency inference rules
IDIR1 (reflexivity): R.X < R.X.
IDIR2 (attribute correspondence): If R.X < S.Y
where X = {A1, A2 ,..., An} and Y = {B1,
B2, ..., Bn} and Ai Corresponds-to Bi, then R.Ai < S.Bi
for 1 ≤ i ≤ n.
IDIR3 (transitivity): If R.X < S.Y and S.Y < T.Z, then R.X < T.Z.
Shadow paging
Advantages:
• Simple recovery, no log in single-user systems (in multi-user systems, logs and
checkpoints needed for concurrency control).
Disadvantages:
• Fragmentation of storage (clustering lost).
• Writing the shadow table to disk takes time.
• Garbage collection of pages needed.
v) Immediate Update recovery
Immediate update
• Updated values from the buffer first to the log, then to the database (even before
commit);
WAL-rule
• The most common in practice.
• Rollback (undo) may occur
• Two alternatives:
– All writes forced to disk before commit
(UNDO/NO-REDO)
– Some writes from buffer to disk after commit
(UNDO/REDO)