3.5创建药品表,药品代码是主码,批号取值唯一
Create table medicine(
Medicinecode char()primary key,
Medicinename varchar(),
Pycode char(),
Dosagefrom char(),standard char(),
Batchnumber char() unique,
Productiondate date,
Expirationdate date,
Category char(),
Yb char())
;
3.7创建供应商表,主码为表级约束
Create table provider(
Providercode char() not null,
Providername char() not null,
Pycode char(),
address char(),
Tel char(),
zip char(),
Email char(),
relation char(),
Primary key(providercode) --主码约束,表级约束
)
;
3.8建立供应表,包含主码、外码,均为标记约束
Create table pm(
Medicinecode char() not null,
Providercode char() not null,
Pmdate date not null,
Price number,
qyt int,
Primary key(medicinecode,providercode,pmdate),
Foreign key(medicinecode) references medicine(medicinecode),
Foreign key(providercode)references provider(providercode)
);
注意:
列级约束:约束条件前有空格隔开的;
表级约束:和定义属性一样,独成一句,以逗号结尾!