Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

T-SQL-8-3 Iplement a trigger that restricts the number of seats at a table to be

ID: 3924569 • Letter: T

Question

T-SQL-8-3

Iplement a trigger that restricts the number of seats at a table to be at least zero and not greater than 8.

DATABASE (key fields are underlined)

EMPLOYEE TABLE: EMP_ID, EMP_LNAME, EMP_STREET, EMP_CITY, EMP_STATE, EMP_ZIP, EMP_START_DATE

TABLES TABLE: TABLE_ID, AREA_ID, TABLE_SEATS

AREA TABLE: AREA_ID, AREA_NAME, AREA_SUPERVISOR_EMPLOYEE_ID

CUSTOMER TABLE: CUST_ID, CUST_LAST_NAME, CUST_NUMBER_OF_GUESTS

ASSIGNMENT TABLE: EMP_ID, TABLE_ID

SEATING TABLE: CUST_ID, TABLE_ID, SEATING_COST, SEATING_DATE, SEATING_TIP

Explanation / Answer

CREATE TRIGGER myTrigger BEFORE INSERT ON tablestable FOR EACH ROW BEGIN IF table_seats8 THEN RAISE_APPLICATION_ERROR( -20002, 'Please Select Valid Number of Seats'); END if;