...

/

Exercise: ACID Properties

Exercise: ACID Properties

Practice and test your understanding of ACID properties.

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.

Write a SQL transaction that attempts to add a new category, Office Supplies, to the Categories table. If successful, commit it. If it somehow fails (e.g., if a constraint was violated), it should theoretically roll back.

Press + to interact
MySQL 8.0
-- Add a new category with transaction and conditional commit or rollback

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

Question 2

Given the structure of the Suppliers table:

Field

Type

SupplierID

int

SupplierName

varchar(50)

Email

varchar(50)

Phone

varchar(15)

Address

varchar(100)

OnTimeDeliveryRate

decimal(5,2)

AvgLeadTime

int

The Suppliers table stores detailed information about the suppliers, such as their name, contact details, and performance metrics.

Write a transaction that attempts to ...