...

/

Exercise: Transactions and Concurrency Control

Exercise: Transactions and Concurrency Control

Practice and test your understanding of transactions and concurrency control.

Let’s get some hands-on practice!

Question 1

Given the following structure of the Categories table:

Field

Type

CategoryID

int

CategoryName

varchar(50)

Where CategoryID is the primary key. The table contains information about categories of products.

Start a transaction, insert a new category named Office Supplies into the Categories table. Then, immediately roll back the transaction. Finally, verify that the Office Supplies category was not permanently added. 

Press + to interact
MySQL 8.0
-- Demonstrating transaction rollback with an insert into the Categories table

If you’re stuck, click the “Show Solution” button.

Question 2

Given the following structure of the Customers table:

Field

Type

CustomerID

int

CustomerName

varchar(50)

Email

varchar(50)

Phone

varchar(15)

Address

varchar(100)

LastLogin

date

CreatedAt

timestamp

CustomerTier

enum('New','Regular','VIP')

ReferralID

int

LoyaltyPoints

int

LastPurchaseDate

date

IsChurnRisk

tinyint(1)

Where CustomerID is the primary key and ReferralID is ...