CodeStudy.net
Toggle Menu
Home
Online Java Compiler
Tutorials
Java Tutorial
Python Tutorial
SQL Database Design
Blog
All Posts
SQL Triggers and Constraints
Review your knowledge of enforcing business rules in databases.
1. Which SQL constraint ensures that each record in a table is uniquely identified?
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
2. Which of the following events can trigger a SQL trigger?
INSERT
UPDATE
DELETE
SELECT
3. A UNIQUE constraint allows multiple NULL values in a column.
True
False
4. What keyword is used to define a trigger that executes after a specified event? (one word)
5. When is a BEFORE trigger executed in SQL?
After the event completes
Before the event starts
During the event execution
Only if the event fails
6. Which of the following are valid trigger timing options in SQL?
BEFORE
AFTER
INSTEAD OF
DURING
7. A FOREIGN KEY constraint must reference a PRIMARY KEY column in another table.
True
False
8. What does the CHECK constraint enforce?
No duplicate values in a column
Referential integrity between tables
All values in a column satisfy a specific condition
A default value when none is provided
9. Which statements about SQL triggers are true?
Triggers can modify data in other tables
Triggers are manually invoked by users
Triggers can enforce business rules
A table can have only one trigger per event
10. Name the constraint that prevents NULL values in a column (two words).
11. Which trigger timing replaces the original event with the trigger's action?
BEFORE
AFTER
INSTEAD OF
DURING
12. The DEFAULT constraint assigns a value to a column only if an explicit value is provided.
True
False
13. Which of these are considered SQL constraints?
PRIMARY KEY
TRIGGER
NOT NULL
INSTEAD OF
UNIQUE
14. What event would cause a trigger defined as AFTER DELETE to execute?
A new row is added to the table
An existing row is updated
A row is removed from the table
The table structure is modified
15. Which constraint is used to automatically assign a value to a column if no value is specified?
DEFAULT
CHECK
UNIQUE
PRIMARY KEY
Reset
Answered 0 of 0 — 0 correct