1. 实体完整性
create table Student(Sno char(9) primary key, Sname char(40) not null,
Ssex char(2), Sage smallint, Sdept char(20));
create table Student(Sno char(9), Sname char(40) not null,
Ssex char(2), Sage smallint, Sdept cahr(20)), primary key(Sno);
create table SC(Sno char(9) not null, Cno char(4) not null,
Grade smallint, primary key (Sno, Cno));
2. 参照完整性
create table SC(Sno char(9) not null, Cno char(4) not null,
Grade smallint, primary key(Sno, Cno),
foreign (Sno) references Studnet(Sno),
foreign key (Cno) references Course(Cno));
create table SC(Sno char(9) not null, Cno char(4) not null,
Grade smallint, primary key (Sno, Cno),
foreign key (Sno) references Student(Sno),
on delete cascade
on update cascade
foreign key(Cno) references Course(Cno),
on delete cascade
on update cascade
);