关于SQL数据库的一个问题

supercsharp 2007-01-17 09:14:35
create table StudentInfo
(
StudentID char(7) not null primary key,
StudentName char(10) not null unique,
StudentAge int null,
StudentBirthday varchar(20) not null,
StudentAddress varchar(50) null,
StudentMobilePhone varchar(11) null,
StudentSex char(2) not null,
StudentPhone char(8) null,
StudentClass char(20) null
)
我设了StudentID为主键,StudentName为Unique约束,然后在下面的表中想定义两个外键约束,使这两个外键约束和StudentID,StudentName有相同的值:
create table StudentGrade
(
StudentID char(7) not null references StudentInfo(StudentID)on update cascade on delete cascade,
StudentName char(10) not null references StudentInfo(StudentID)on update cascade on delete cascade,
MathGrade int not null check(MathGrade >0 and MathGrade<100),
ChineseGrade int not null check(ChineseGrade>0 and ChineseGrade<100),
EnglishGrade int not null check(EnglishGrade>0 and EnglishGrade<100),
TotleGrade int null ,
EvenGrade int null ,
ClassRate int null check (ClassRate>0),
GradeRate int null check (GradeRate>0)
)
我想使这个表中的StudentID,StudentName和上面表中的StudentID,StudentName相对应,应该怎么实现?
...全文
180 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧