学生
Student {
s_id int primary key,
s_name nvarchar(10) not null,
s_sex nchar(1) not null check(s_sex=’男’ or s_sex=’女’),
s_class int not null,
s_address nvarchar(50),
s_credit int default(0),
s_time date default(getDate()),
}
教师
Teacher {
t_id int primary key,
t_name nchar(10) not null,
t_sex nvarchar(1) not null check(s_sex=’男’ or s_sex=’女’),
}
院系
Department {
d_id int primary key,
d_name nvarchar(10) not null
}
专业
Specialty {
s_id int primary key,
s_name nvarchar(10) not null,
s_department int not null
}
班级
Class {
c_id int primary key,
c_name nvarchar(10) not null,
c_specialty int not null
}
课程
Course {
c_id int primary key,
c_name nvarchar(10) not null,
c_category int not null,
c_emphasis bit not null default(0),
c_type nvarchar(10) not null,
c_credit int not null,
c_theoryTime int check(c_theoryTime>0),
c_practiceTime int check(c_practiceTime >0),
c_methods nchar(2) not null check(s_methods = ’考试’ or s_methods = ‘考查’),
c_specialty int not null,
}
课程类别
CourseCategory {
c_id int primary key,
c_name nvarchar(10) not null,
c_property nvarchar(10) not null,
c_credit int not null check(c_credit > 0),
c_time int check(c_time > 0),
c_remarks nvarchar(50)
}
中间表对应“多对多的关系”
(学生,课程)
StudentDetails {
s_studentId int,
s_courseId int,
s_teacherId int,
s_score int not null default(0) check(s_score > 0),
s_time varchar(10) not null,
s_term int not null,
primary key(s_studentId, s_courseId)
}
(院系,课程)
SpecialtyDetails {
s_specialtyId int,
s_courseId int,
primary key(s_specialtyId,s_courseId)
}
E-R图设计
写于2013-04-16 10:35