008.建立主从表(sql实例)

CREATE TABLE info
(
snumb int primary key identity(1,1),
sname varchar(20),
sex bit,
birthday datetime check(birthday<getdate()),
[address] varchar(50),
tel varchar(30)
)
CREATE TABLE lesson
(
ccode varchar(5)primary key,
cname varchar(40),
cnum int
)
CREATE TABLE score
(
snumb int foreign key references info(snumb),
ccode varchar(5)foreign key references lesson(ccode),
score int check(score>0)
)

posted @ 2017-01-20 20:25  90后梦想大师  阅读(801)  评论(0编辑  收藏  举报