CREATE TABLE Company (
cId VARCHAR2(50) PRIMARY KEY ,
cName VARCHAR2(50) NOT NULL ,
cAdd VARCHAR2(50) NULL ,
cPhone VARCHAR2(50) NULL ,
cManager VARCHAR2(50) NULL ,
cremark VARCHAR2(50) NULL
);
INSERT INTO Company VALUES ('1','保洁','广东','13900000000','李平','保洁公司');
INSERT INTO Company VALUES ('2','康师傅','广东','13811111111','张三','食品');
CREATE TABLE Mtype (
tId VARCHAR2(50) PRIMARY KEY ,
tName VARCHAR2(50) NOT NULL ,
tremark VARCHAR2(30) NULL
);
INSERT INTO Mtype VALUES ('1','洗漱用品','食品');
INSERT INTO Mtype VALUES ('2','食品','食品');
INSERT INTO Mtype VALUES ('3','电子产品','电子产品');
INSERT INTO Mtype VALUES ('4','家用电器','家用电器');
INSERT INTO Mtype VALUES ('5','生活用品','生活用品');
CREATE TABLE Merchandise (
mId VARCHAR2(50) NOT NULL ,
cId VARCHAR2(50) NOT NULL ,
tId VARCHAR2(50) NOT NULL ,
mName VARCHAR2(50) NOT NULL ,
mPrice VARCHAR2(50) NOT NULL ,
mSpec VARCHAR2(50) NULL ,
mUnits VARCHAR2(50) NULL ,
mPurchasePrice VARCHAR2(50) NOT NULL ,
mCheckTerm VARCHAR2(50) NULL ,
mremark VARCHAR2(50) NULL ,
PRIMARY KEY (mId),
FOREIGN KEY (cId) REFERENCES Company (cId),
FOREIGN KEY (tId) REFERENCES Mtype (tId)
);
INSERT INTO Merchandise VALUES ('1','1','1','海飞丝','18','500ml','瓶','12','');
INSERT INTO Merchandise VALUES ('2','2','2','康师傅方便面','2','100g','袋','1','');
CREATE TABLE UserKinds (
kId VARCHAR2(50) PRIMARY KEY ,
kName VARCHAR2(50) NOT NULL ,
kremark VARCHAR2(50) NULL
);
INSERT INTO UserKinds VALUES ('1','管理员','管理员');
INSERT INTO UserKinds VALUES ('2','收银员','收银员');
CREATE TABLE Guest (
gId VARCHAR2(50) NOT NULL ,
gName VARCHAR2(50) NOT NULL ,
gPassword VARCHAR2(50) NULL ,
kId VARCHAR2(50) NOT NULL ,
gremark VARCHAR2(50) NULL ,
PRIMARY KEY (gId),
FOREIGN KEY (kId) REFERENCES UserKinds (kId)
);
INSERT INTO Guest VALUES ('11111','李平','11111','2','');
INSERT INTO Guest VALUES ('22222','李平','22222','1','');
CREATE TABLE Enterstock (
eId VARCHAR2(50) NOT NULL ,
mId VARCHAR2(50) NOT NULL ,
eNumber VARCHAR2(50) NOT NULL ,
mPurchasePrice VARCHAR2(50) NOT NULL ,
edate VARCHAR2(50) NOT NULL ,
eRemark VARCHAR2(50) NULL ,
PRIMARY KEY (eId),
FOREIGN KEY (mId) REFERENCES Merchandise (mId)
);
INSERT INTO Enterstock VALUES ('1','1','120','12','2009-6-9','111');
INSERT INTO Enterstock VALUES ('2','2','200','1','2009-6-9','1111');
CREATE TABLE Stock (
mId VARCHAR2(50) PRIMARY KEY ,
amount VARCHAR2(50) NOT NULL ,
sremark VARCHAR2(30) NULL ,
FOREIGN KEY (mId) REFERENCES Merchandise (mId)
);
CREATE TABLE Sall (
sId VARCHAR2(50) NOT NULL ,
gId VARCHAR2(50) NOT NULL ,
sDate VARCHAR2(50) NOT NULL ,
sNumber VARCHAR2(50) NOT NULL ,
sPrice VARCHAR2(50) NOT NULL ,
sremark VARCHAR2(50) NULL ,
PRIMARY KEY (sId),
FOREIGN KEY (gId) REFERENCES Guest (gId)
);
CREATE TABLE MS (
sId VARCHAR2(50) NOT NULL ,
mId VARCHAR2(50) NOT NULL ,
mAmount VARCHAR2(50) NOT NULL ,
remark VARCHAR2(50) NULL ,
PRIMARY KEY (sId,mId),
FOREIGN KEY (sId) REFERENCES Sall (sId),
FOREIGN KEY (mId) REFERENCES Merchandise (mId)
);
评论4