MySQL is an open-source relational database management system. It is one of the most widely used databases and is prominent in the popular LAMP stack.
A database trigger is a procedural code that is automatically executed in response to certain events on a particular table or view in a database. It's often used to enforce data integrity and, as such, is an important topic for all developers.
Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.
This is a part of latest question addition to our question library.
Fill in the blanks so that the trigger item_delete inserts name from item table to the item_archive table, after a row from the table item is deleted.
CREATE TABLE item ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, quantity INT NOT NULL ); CREATE TABLE item_archive ( archive_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL ); DELIMITER $$ CREATE item_delete ON item FOR EACH ROW BEGIN INSERT INTO item_archive(name) VALUES (); END; $$ DELIMITER ;
See the example case for more details.