0% found this document useful (0 votes)
58 views

Assignment 3

The document discusses several topics: 1. It explains serializability and types of serializability including conflict serializability and view serializability. 2. It provides code examples for basic JDBC operations like insert, select, delete, and update in Java along with the output. 3. It describes crash recovery in databases and transaction failure as reasons a recovery may need to occur. 4. It defines different types of locks like binary and compatibility locks used for lock management in databases. 5. It discusses the "phantom" algorithm, a stealth Google update that targeted websites with low quality, thin, or affiliate content.

Uploaded by

Naveen Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Assignment 3

The document discusses several topics: 1. It explains serializability and types of serializability including conflict serializability and view serializability. 2. It provides code examples for basic JDBC operations like insert, select, delete, and update in Java along with the output. 3. It describes crash recovery in databases and transaction failure as reasons a recovery may need to occur. 4. It defines different types of locks like binary and compatibility locks used for lock management in databases. 5. It discusses the "phantom" algorithm, a stealth Google update that targeted websites with low quality, thin, or affiliate content.

Uploaded by

Naveen Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ASSIGNMENT – 3

Q1) Explain Serializibility and Types of serializability?

A)Serializability is the classical concurrency scheme. It ensures that a schedule


for executing concurrent transactions is equivalent to one that executes the
transactions serially in some order. It assumes that all accesses to the database are
done using read and write operations.

A schedule is called ``correct'' if we can find a serial schedule that is ``equivalent''


to it. Given a set of transactions T1...Tn, two schedules S1 and S2 of these
transactions are equivalent if the following conditions are satisfied:

Read-Write Synchronization:

If a transaction reads a value written by another transaction in one schedule,


then it also does so in the other schedule.

Write-Write Synchronization:

If a transaction overwrites the value of another transaction in one schedule, it


also does so in the other schedule.

These two properties ensure that there can be no difference in the effects of the
two schedules.

There are several approaches to enforcing serializability. A non-serial schedule


of n number of transactions is said to be serializable schedule, if it is equivalent
to the serial schedule of those n transactions. A serial schedule doesn’t allow
concurrency, only one transaction executes at a time and the other starts
when the already running transaction finished.

Types of serializbility are

1.Conflict serializability
2. View serializability

Conflict serializability:
A schedule is called conflict serializable if we can convert it into a serial
schedule after swapping its non-conflicting operations.
1. Both the operations should belong to different transactions.
2. Both the operations are working on same data item.
3. At least one of the operations is a write operation.

View serializability:
View Serializability is a process to find out that a given schedule is view
serializable or not.

To check whether a given schedule is view serializable, we need to check


whether the given schedule is to its serial schedule. Let’s take an example to
understand what I mean by that.

Q2) JDBC Connectivity –Insert, Select, Delete, and Update with program
code and outputs.
 JDBC INSERT:

import java.sql.*;

public class insert1


{
public static void main(String args[])
{
String id = "121710303040";
String pwd = "password";
String fullname = "naveenredmi9s";
String email = "[email protected]";

try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:orcl", "121710303040", "password");
Statement stmt = con.createStatement();

// Inserting data in database


String q1 = "insert into userid values('" +id+ "', '" +pwd+
"', '" +fullname+ "', '" +email+ "')";
int x = stmt. executeUpdate(q1);
if (x > 0)
System.out.println("Successfully Inserted");
else
System.out.println("Insert Failed");

con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

Output : Successfully Registered

 JDBC SELECT :

import java.sql.*;

public class select


{
public static void main(String args[])
{
String id = "121710303040";
String pwd = "password";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:orcl", "l121710303040", "password");
Statement stmt = con.createStatement();

// SELECT query
String q1 = "select * from userid WHERE id = '" + id +
"' AND pwd = '" + pwd + "'";
ResultSet rs = stmt.executeQuery(q1);
if (rs.next())
{
System.out.println("User-Id : " + rs.getString(1));
System.out.println("Full Name :" + rs.getString(3));
System.out.println("E-mail :" + rs.getString(4));
}
else
{
System.out.println("No such user id is already registered");
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
Output : user id : 12171033040
Full name : naveenredmi9s
e-mail : [email protected]

 JDBC DELETE :

import java.sql.*;

public class delete


{
public static void main(String args[])
{
String id = "121710309062";
String pwd = "password2";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();

// Deleting from database


String q1 = "DELETE from userid WHERE id = '" + id +
"' AND pwd = '" + pwd + "'";

int x = stmt.executeUpdate(q1);

if (x > 0)
System.out.println("One User Successfully Deleted");
else
System.out.println("ERROR OCCURED :(");

con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Output : One User Successfully Deleted

 JDBC UPDATE :

import java.sql.*;

public class update1


{
public static void main(String args[])
{
String id = "121710303040";
String pwd = "password";
String newPwd = "doormamu";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();

// Updating database
String q1 = "UPDATE userid set pwd = '" + newPwd +
"' WHERE id = '" +id+ "' AND pwd = '" + pwd + "'";
int x = stmt.executeUpdate(q1);

if (x > 0)
System.out.println("Password Successfully Updated");
else
System.out.println("ERROR OCCURED :(");

con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Output : Password Successfully Updated
Q3) Explain Crash Recovery

A) DBMS is a highly complex system with hundreds of transactions being


executed every second. The durability and robustness of a DBMS depends on
its complex architecture and its underlying hardware and system software. If it
fails or crashes amid transactions, it is expected that the system would follow
some sort of algorithm or techniques to recover lost data.

Transaction failure
A transaction has to abort when it fails to execute or when it reaches a point from
where it can’t go any further. This is called transaction failure where only a few
transactions or processes are hurt.
Reasons for a transaction failure could be −
 Logical errors − Where a transaction cannot complete because it has
some code error or any internal error condition.
 System errors − Where the database system itself terminates an active
transaction because the DBMS is not able to execute it, or it has to stop
because of some system condition. For example, in case of deadlock or
resource unavailability, the system aborts an active transaction.

Q4) Explain Lock Management and types of Locks


A ) A lock is a variable associated with a data item that describes the status of
the item with respect to possible operations that can be applied to it. Generally,
there is one lock for each data item in database Locks are used as a means of
synchronizing the access by concurrent transactions to the database item.
Types of lock :

 Binary lock
 Compatibility lock

Binary lock :

A binary lock can have two states or values: locked and unlocked.
A distinct lock is associated with each database item A. If the value of the lock
on A is 1, item A cannot be accessed by a database operation that requests the
item. If the value of the lock on A is 0 then item can be accessed when requested.
We refer to the current value of the lock associated with item A as LOCK
(A). There are two operations, lock item and unlock item are used with binary
locking A transaction requests access to an item A by first issuing a lock item
(A) operation. If LOCK (A) = 1, the transaction is forced to wait. If LOCK (A) =
0 it is set to 1 (the transaction locks the item) and the transaction is allowed to
access item A. When the transaction is through using the item, it issues an
unlock item (A) operation, which sets LOCK (A) to 0 (unlocks the item) so
that A may be accessed by other transactions. Hence binary lock enforces mutual
exclusiol1 on the data item.

Compatibility lock :

Suppose that there are A and B two different locking modes. If a transaction T1
requests a lock of mode on item Q on which transaction T2 currently hold a
lock of mode B. If transaction can be granted lock, in spite of the presence of
the mode B lock, then we say mode A is compatible with mode B.

Q5) Explain Phantom Algorithm


A) A Google “phantom” algorithm is rolling out since the May 8th and seems
to have impacted many websites and especially websites sharing “how-to”
content. Sites like HubPages, eHow, WikiHow and Answers.com have seen
their ranking drop drastically.
Glenn Gabe, from G-Squared Interactive, is the one who called this update
“Phantom” since it comes by surprise and because Google did not confirm first
its existence.
As this update shares common ranking factors with Panda it seems to penalize
sites with:

 low quality content


 thin content
 affiliate content
 clickbait article
 too many ads
 pop-ups
 stacked videos
 pages difficult to navigate
The Google Phantom update (or core algorithm update) is a change in
the algorithms of the search engines which led to some major changes in
the SERP positions of numerous websites. Google initially denied such changes
but then confirmed the update after increased demands from experts and key
media. Therefore, the update that was meant to address the quality of websites
was called Phantom.

*****************************************************************************************

You might also like