
74 PUZZLE 16 MECHANICS
CREATE TABLE Teams
(job_id INTEGER NOT NULL REFERENCES Jobs(job_id),
primary_mech INTEGER NOT NULL,
primary_type CHAR(10) DEFAULT ‘Primary’ NOT NULL
CHECK (primary_type = ‘Primary’)
REFERENCES Personnel(emp_id, mech_type),
assist_mech INTEGER NOT NULL
assist_type CHAR(10) DEFAULT ‘Assistant’ NOT NULL
CHECK (assist_type = ‘Assistant’)
REFERENCES Personnel(emp_id, mech_type),
CONSTRAINT at_least_one_mechanic
CHECK(COALESCE (primary_mech, assist_mech) IS NOT NULL),
...);
Now it should work.