create database stu
use database stu
go
create table s(
sid varchar(50) not null primary key,
sname varchar(50) not null,
sex char(5),
snation char(5),
sbirthday datetime(8),
stime datetime(8),
sclassid varchar(50),
shome varchar(50),
selse char(50))
create table class(
classid varchar(50) not null primary key,
classname varchar(50) not null,
classdepartment varchar(50),
classcollege varchar(50),
classteacherid varchar(50))
create table t(
tid varchar(50) not null primary key,
tname varchar(50) not null,
tcollege varchar(50))
create table tc(
tcid int not null primary key,
tid varchar(50) not null,--外键
cid varchar(50) not null,--外键
classid varchar(50) not null,--外键
foreign key(tid)references t(tid),
foreign key(cid)references c(cid),
foreign key(classid)references class(classid),
cyear char(5))
create table c(
cid varchar(50) not null primary key,
cname varchar(50) not null,
cperiod int,
ccredit int,
ckind int,
cdescribe varchar(50))
create table sc(
scid bigint not null primary key,
sid varchar(50) not null,--外键
cid varchar(50) not null,--外键
foreign key(sid)references s(sid),
foreign key(cid)references c(cid),
sgrade int,
cyear char(5))