ZiBaT => Peter
Levinsky => PBA-Database => exercise |
|
Updated : 2018-03-16
|
What is a trigger see wiki - database trigger
SERVER chap 15, p. 537-559
Reference Triggers :
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql
examples: https://www.mssqltips.com/sqlservertutorial/2911/working-with-triggers/
https://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html
examples: http://www.mysqltutorial.org/create-the-first-trigger-in-mysql.aspx
Triggers:
http://www.sqlteam.com/article/an-introduction-to-triggers-part-i
http://www.sqlteam.com/article/an-introduction-to-triggers-part-ii
Previous exercises (basis for this exercise) PetersPanSQLexercise1.htm
For the 'RestaurantTable' table, make a trigger to control the Seats before insert a row into the table.
The Seats must be between 0 and 12 otherwise it should not be inserted.
Could you do this in another way? if yes how?
Make trigger that print the information that is inserted in the Booking table
First just print it on the screen. (e.g print ' ... the text .... ' )
Make trigger that Make a new row in a new table 'OldBookings' if a Booking is deleted
Create a new table 'OldBooking' having the information of a Booking but also a new field the date and time of the deletion.
For the Booking table
Let say a business rule tells a Customer can not have more than 10 bookings.
Make a trigger to check, that the number of bookings of the Customer do not exceed 10 otherwise it should not be inserted.
Extra A : Auto filling of field informations
For the Booking Table modify the table to have DayAndTimeOfBooking.
When insert make a trigger to insert current day and time of the booking.