createtablecollege(coll_idchar(2)primarykey,coll_namevarchar(30)notnull);createtabledept(dept_idchar(4)primarykey,coll_idchar(2)notnull,dept_namevarchar(30),constraintdep...
create table college(
coll_id char(2) primary key,coll_name varchar(30) not null
);
create table dept(
dept_id char(4) primary key,coll_id char(2) not null,dept_name varchar(30),
constraint dept_fk foreign key(coll_id) references college(coll_id)
);
create table class(
class_id char(6) primary key,dept_id char(4) not null,coll_id char(2),
class_name varchar(6) not null,
constraint class_fk1 foreign key(dept_id) references dept(dept_id),
constraint class_fk2 foreign key(coll_id) references college(coll_id)
);
create table student(
stu_id char(12) primary key,stu_name varchar(20) not null,stu_gender char(2)
check(stu_gender='男' or stu_gender='女'),stu_birth datetime,
nativeplace varchar(60),coll_id char(2) not null,dept_id char(4) not null,
class_id char(6) not null,cometime datetime not null,
constraint stu_fk1 foreign key(class_id) references class(class_id),
constraint stu_fk2 foreign key(dept_id) references dept(dept_id),
constraint stu_fk3 foreign key(coll_id) references college(coll_id)
);
create table course(
cou_id char(6) primary key,cou_name varchar(30) not null,xuefen numeric(3,1) not null,
coll_id char(2) not null,dept_id char(4) not null,
constraint cou_fk1 foreign key(dept_id) references dept(dept_id),
constraint cou_fk2 foreign key(coll_id) references college(coll_id)
);
上述代码中,primary key是什么意思,not null 是什么意思 foreign key是什么意思 numeric是什么类型
constraint dept_fk foreign key(coll_id) references college(coll_id)这些语句是什么意思
展开