Search⌘ K
AI Features

Question: Triggers

Explore how to create MySQL triggers that detect stock increases and update the LastRestockDate automatically. This lesson guides you through using OLD and NEW row values and conditional logic to automate inventory tracking.

Question

Given the following structure of the Products table:

Field

Type

ProductID

int (Primary Key)

ProductName

varchar(50)

CategoryID

int

Price

decimal(10,2)

Stock

int

LastRestockDate

date

MonthlySales

int

InventoryTurnoverRate

decimal(5,2)

Where, ProductID is the primary key and CategoryID is the foreign key referencing the Categories table. The table contains information about products available in the ...