我有一张桌子依赖
CREATE TABLE DEPENDANT (DEPENDANT_NM VARCHAR2(15) PRIMARY KEY,
DEP_GENDER CHAR(1), DEP_BDAT DATE, RELATED_HOW VARCHAR2 (8), ESSNO CHAR(9));
ALTER TABLE DEPENDANT ADD CONSTRAINT FK_ESSNO FOREIGN KEY (ESSNO)
REFERENCES HW_EMPLOYEE(SSNO);
ALTER TABLE DEPENDANT ADD CONSTRAINT CK_DEP_GENDER CHECK
(DEP_GENDER IN ('M','F'));
我需要添加一个约束,以确保女性家属只能被视为“女儿”或“配偶”,而男性家属只能被视为“儿子”或“配偶”
我是否使用检查约束,例如...
ALTER TABLE DEPENDANT ADD CONSTRAINT CK_RELATEDF CHECK (DEP_GENDER = 'F' AND
RELATED_HOW IN('Daughter' OR 'Spouse'));