I am learning SQL and have some tables similar to the following:
Person (id*, name) Customer(id*, is_active, ...) Employee(id*, department_id, ...)
(* indicates the primary key, which in the case of the Client and the Employee is both PC and FK for the Person)
Both Clients and Employees are types of Person, and I want to make sure that when the record is inserted into the Person, the record must also be inserted into the EITHER Customer or Employee, but NOT IT. A person cannot be both an employee and a client within the framework of this example.
I was told that a trigger would be useful for enforcing this restriction. Can someone explain the use of a trigger with this simple example?
source share