I am learning SQL and have some tables much like the following:
Person (id*, name)
Customer(id*, is_active, ...)
Employee(id*, department_id, ...)
(the * indicates the primary key, which in the case of Customer and Employee is both a PK and a FK back to Person)
Both Customer and Employee are types of Person, and I want to ensure that when a record is inserted into Person a record must also be inserted into EITHER Customer or Employee but NOT both. A Person cannot be both an employee and customer within the limits of this example.
I have been told that a Trigger would be useful to enforce this constraint. Could somebody please explain the usage of a trigger with this simple example?