CREATE TABLE User0
(
U_phone_num INT NOT NULL,
U_name VARCHAR2(20) NULL,
Address VARCHAR2(20) NULL,
Birth DATE NULL,
Counselor VARCHAR2(20) NULL,
Goods_num INT NULL,
couns_num INT NULL,
CONSTRAINT USERS_PK PRIMARY KEY (U_phone_num)
);
CREATE TABLE Manager0
(
Emp_num INT NOT NULL,
M_name VARCHAR2(20) NULL,
Address VARCHAR2(20) NULL,
M_Phone_num VARCHAR2(20) NULL,
U_Phone_num INT NULL,
CONSTRAINT MANAGER_PK PRIMARY KEY (Emp_num)
);
CREATE TABLE Goods
(
Code_num INT NOT NULL,
Company VARCHAR2(20) NULL,
G_name VARCHAR2(20) NULL,
price INT NULL,
option_ INT NULL,
CONSTRAINT GOODS_PK PRIMARY KEY (Code_num)
);
CREATE TABLE Status
(
Apply_code INT NOT NULL,
Goods_name VARCHAR2(20) NULL,
Counselor VARCHAR2(20) NULL,
Username VARCHAR2(20) NULL,
Date_ DATE NULL,
IsOpen INT NULL,
Goods_company VARCHAR2(20) NULL,
Goods_Price INT NULL,
EMP_NUM INT NULL,
Goods_NUM INT NULL,
U_Phone_Num INT NULL,
CONSTRAINT STATUS_PK PRIMARY KEY (Apply_code)
);
ALTER TABLE User0
ADD CONSTRAINT FK_User0_COUNS_NUM_MANAGER0_EMP_NUM FOREIGN KEY (COUNS_NUM)
REFERENCES user0 (COUNS_NUM);
ALTER TABLE Status
ADD CONSTRAINT FK_Status_Goods_NUM_GOODS_CODE_NUM FOREIGN KEY (Goods_NUM)
REFERENCES Status (Goods_NUM);
ALTER TABLE Status
ADD CONSTRAINT FK_Status_U_PHONE_NUM_USER0_U_PHONE_NUM FOREIGN KEY (U_PHONE_NUM)
REFERENCES Status (U_PHONE_NUM);
ALTER TABLE Status
ADD CONSTRAINT FK_Status_EMP_NUM_MANAGER0_EMP_NUM FOREIGN KEY (EMP_NUM)
REFERENCES Status (EMP_NUM);
ALTER TABLE User0
ADD CONSTRAINT FK_users_Goods_num_goods_Code_ FOREIGN KEY (Goods_num)
REFERENCES goods (Code_num);