7 hours 36 minutes
I welcome back to Module five sequel development. This is less than three triggers, and this lesson is going to have a few different sub lessons that linked together to create a nicely formed procedure that works off a trigger to record when an article is deleted.
And this is an example of an audit trigger that you might want to implement
when certain actions such as the leading important objects occurs because occasionally you will have users delete objects, and either they forget that they have deleted it or they don't realize that they've deleted it. And it's a good idea to have some kind of audit trails so that you can tell that it's been deleted.
you may create this perception that data is just disappearing.
So with that said, let's go ahead and get started.
We're currently in sub Listen,
three point to the audit table, so first things first, we're gonna go ahead and create the audit table that will get populated when an article is deleted.
So that said, Let's right, click on our tables,
select, create new table.
We'll go to the Properties tab. We're gonna go ahead and call this audit table
when I had a new column, we're gonna make it the i d column.
And I'm gonna use the same data type that we've been using.
Big Ant. Unsigned. Not know.
on the next new column is gonna be a bar charcoal. We're gonna call it
Actually, we're gonna call it Ah,
And it's a bar Char 100. It's not allowed to be. Noah needs to be filled in,
And then we're gonna select create new column, and we're going to create
we could probably use of arch are 100.
But I'm just gonna provide some extra space and just go ahead and use tax
on. Don't say that. Can't be no either.
Let's go ahead and save that.
We had an ad in our primary key.
I mean, Okay,
let's go back to let's go in and save that persists.
Then we'll go ahead and go to our auto and turn on our auto increment on the I D column. Save that.
So that completes our audit table. It's a pretty simple table. Basically, we're goingto have an event type,
which is purposely broad. So right now we're handling a delete event. So, for example, when a deletion of an article occurs, the event type will be article delete
with a description off article with I D and Title was deleted at this time
that will be that will make for a reasonably good audit. Trail will be able to see when articles were deleted
by their idea and title and their date in time and then down the road of anyone. Ever
ask what happened to an article? It seems to have vanished. We'll be able to check the audit table and see if it was deleted.
With that said, that completes this lesson, and I hope to see you in the next one.