[Solved] CSCI466-Assignment 9 Transactions in MariaDB

$25

File Name: CSCI466-Assignment_9_Transactions_in_MariaDB.zip
File Size: 414.48 KB

SKU: [Solved] CSCI466-Assignment 9 Transactions in MariaDB Category: Tag:
5/5 - (1 vote)

The purpose of this assignment is to experiment with the behavior of transactions using a MariaDB database. You will need to use morethanone MariaDB session for these to work. To do this, just open up two separate putty sessions to turing or hopper and log into MariaDB on each of them. Use the same name for the output file for all of the sessions T assign9out.txt so that the output from all of your sessions ends up in the same file. When znnnnnnn is used, replace it with your own z-id.

Part I The Power of COMMIT

1) Start your first MariaDB seesion, issue the following SQL queries:

T assign9out.txt

USE znnnnnnn;

CREATE TABLE Fall( pk INT PRIMARY KEY, data CHAR(15));

START TRANSACTION;

INSERT INTO Fall

VALUES(1, dataA);

INSERT INTO Fall

VALUES(2, dataB);

INSERT INTO Fall

VALUES(3, dataC);

  • Start your second MariaDB session, and run the following SQL queries in it.

T assign9out.txt

USE znnnnnnn;

SELECT * from Fall;

Question1.2) What is the result of running the SELECT statement. Why?

  • In that second session, run the following:

INSERT INTO FalI VALUES(4, dataD);

INSERT INTO Fall VALUES(5, dataE);

  • Switching back to the first MariaDB session, issue the following queries:

COMMIT;

SELECT * FROM Fall;

t exit;

  • Switch back to the second MariaDB instance, and run the following queries:

SELECT * FROM Fall;

t exit;

Question1.5) What is the result of the SELECT statement above?

Part II The Power of ROLLBACK

  • Start another MariaDB session, issue following MariaDB statements:

T assign9out.txt

USE znnnnnnn;

START TRANSACTION;

DELETE FROM Fall WHERE pk = 3; SELECT * FROM fall;

  • Then

UPDATE Fall

SET Data = changed WHERE pk = 2;

  • Then

UPDATE Fall

SET Data = changed 2 WHERE pk = 4;

  • Then

INSERT INTO Fall VALUES(6, dataF);

SELECT * FROM Spring;

Question2.4) What is the result of the SELECT statement, and why?

  • Issue the following MariaDB statements:

ROLLBACK;

SELECT * FROM Fall;

Question2.5) What is the result of the SELECT statement, and why?

t exit;

Part III: Be Aware of Deadlock

Using another two sessions of MariaDB, do the following in the order specified: 1) In session 1,

T assign9out.txt

USE znnnnnn; START TRANSACTION;

  • In session 2,

T assign9out.txt

USE znnnnnn; START TRANSACTION;

  • In session 1,

UPDATE Fall

SET data = data1A WHERE pk=1; 4) In session 2,

UPDATE Fall

SET data= data2B WHERE pk = 2;

5) In session 1,

UPDATE Fall

SET data = data5E WHERE pk = 5; 6) In session 2,

UPDATE Fall

SET DAta = data12B WHERE pk = 1;

Question3) What happened here?

Notes

There may be typos in these statements. If there is a syntax error, fix it. These errors were made to encourage you to pay close attention, and to type the statements in yourself as practice.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCI466-Assignment 9 Transactions in MariaDB
$25