我想修改以下 DDL 以添加 CHECK 约束,以便商店的经理在同一家商店工作,并且如果商店的类型为“本地”,则商店会提供所有产品。
任何人都可以帮忙吗?
CREATE TABLE employee(
employee_number CHAR(5) NOT NULL,
name VARCHAR(30),
store_code CHAR(5)
PRIMARY KEY(employee_number),
FOREIGN KEY(store_code) REFERENCES store
)
CREATE TABLE store(
store_code CHAR(5) NOT NULL,
type VARCHAR(15),
employee_number CHAR(5),
PRIMARY KEY(store_code),
FOREIGN KEY(employee_number) REFERENCES employee
)
CREATE TABLE product(
product_code CHAR(5) NOT NULL,
description VARCHAR(150),
cost DEC(10,2),
PRIMARY KEY(product_code)
)
CREATE TABLE stocks(
store_code CHAR(5) NOT NULL,
product_code CHAR(5) NOT NULL,
PRIMARY KEY(product_code, store_code),
FOREIGN KEY(product_key) REFERENCES product,
FOREIGN KEY(store_code) REFERENCES store
)