From the course: MySQL Database Administration
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Solution: Triggers - MySQL Tutorial
From the course: MySQL Database Administration
Solution: Triggers
- [Instructor] Alright, this is the solution video for your assignment on triggers. Hopefully, you were able to get to the solution on your own, and if not, I'll walk you through in a moment. As a reminder, Joe would like you to help him set up his database so that any time a record is written to customer_orders, his staff table is updated to reflect an increased count of total orders served by that staff member. Let's jump into Workbench and I'll show you how that's done. Okay, so first, let's run a SELECT star FROM staff, just so you can see these records. And you see here, we have staff ID of one and two, Rachel and Monica. And then we have the total orders served, which is 10 for each of these employees. So first we're going to want to create a trigger, and I'll show you the code for that in a minute, then we'll be inserting these four records into the customer_orders table. And we're going to want the staff ID to be updated, so we want these 10s to be changed to reflect increased…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Creating an index4m 41s
-
(Locked)
The UNIQUE constraint4m 8s
-
(Locked)
The NOT NULL constraint3m 59s
-
(Locked)
Challenge: Indexes and constraints1m 12s
-
(Locked)
Solution: Indexes and constraints9m 24s
-
(Locked)
Stored procedures6m 27s
-
(Locked)
Challenge: Stored procedures2m 3s
-
(Locked)
Solution: Stored procedures4m 23s
-
(Locked)
Triggers7m 50s
-
(Locked)
Challenge: Triggers1m 41s
-
(Locked)
Solution: Triggers5m 8s
-
(Locked)
-
-