家教中心管理系统数据库设计说明书组号:______________________成员:__ ________ _______1、总体ER图设计2、数据库逻辑结构2.1命名规则1、表命名:使用英文字母(可以使用汉语拼音)。
单词首字母大写。
2、列命名:使用英文字母(可以使用汉语拼音)。
单词首字母大写。
3、约束命名:使用表名或列名组合及约束类型,中间使用“_”连接。
2.2关系分析1.用户信息表Users(User_id,User_name,User_pwd, Type)分析:因为User_id是主键,而且User_name不允许重复,所以主键只有一个属性,不存在部分依赖,又因为User_id User_name,所以不存在非主属性对主键User_id的传递依赖,所以该关系属于3NF。
2.学员信息表Student(Sno, SUser_id, SName , SSex, Birthday, Town, Other, Phone, Pname, School, Grade, Study)分析:因为只有Sno是主键,所以不存在部分依赖,因此该关系属于2NF。
但存在非主属性Pname通过Phone对主键Sno的传递依赖,所以该关系不属于3NF。
3.教员信息表Teacher(Tno, Tuser_id, Tname, Tsex, Birthday, Photo, Station, Introduction, Degree, School, Major)分析:因为只有Tno是主键,且不存在部分依赖跟传递依赖,所以该关系也属于3NF。
4.课程信息表Course(Cno, Cname)分析:从这表可以很明显地看到,只有Cno是主键,且不存在部分依赖跟传递依赖,所以该关系也属于3NF。
5.学员/教员课程信息表STC(STCno , User_id, Cno, Money, Day)分析:此表只有STCno是主键,则不存在部分依赖,又不存在非主属性对主键的传递依赖,所以该关系属于3NF。
6.教授情况表Jiaoshou(Jno, Sno, Tno, Cno , Ano, Type)分析:此表中Jno是主键,除此之外其他都不是主键,且又不存在非主属性对主键的传递依赖,所以该关系属于3NF。
7.协议表Agreement(Ano , Content , Time , Limit)分析:这表中只有Ano是主键,所以不存在部分依赖,又不存在非主属性对主键Ano的传递依赖,所以这关系也属于3NF。
8.公告信息表Placard(Pno, Title , Content , Time)分析:此表主键只有Pno是而已,且不存在部分依赖跟传递依赖,所以此关系也属于3NF。
9.服务反馈表ServiceInfo(Sino, User_id, Time , Mangyidu , Advice )分析:因为只有Sino是主键,所以不存在部分依赖,又不存在非主属性对主键Sino的传递依赖,所以此关系属于3NF。
10.费用表Fee(Fno , FeeType, Price)分析:因为只有Fno是主键,所以肯定不存在部分依赖,且又不存在传递依赖,所以这关系属于3NF。
11.教学评价表Evaluate(Eno, Sno, Tno, Scale, Remark , Time)分析:此表中只有Eno是主键,又不存在部分依赖跟传递依赖,所以此关系属于3NF。
12.匹配信息表Matching(Mno, Sno, Tno , Time, Limit)分析:因为只有Mno是主键,所以不存在部分依赖,又不存在非主属性对主键Mno的传递依赖,所以此关系属于3NF。
13.缴纳信息表Pay(Pno, Sno, Fno, Time, Remark, Way)分析:因为只有Pno是主键,所以不存在部分依赖,又不存在非主属性对主键Pno的传递依赖,所以此关系属于3NF。
2.3 表信息2.3.1表汇总2.3.2用户信息表2.3.3 学员信息表2.3.4 教员信息表2.3.5 课程信息表2.3.6 学员/教员课程信息表2.3.7 教授情况表2.3.8 协议表2.3.9 公告信息表2.3.10 服务反馈表2.3.11 费用表2.3.12 教学评价表2.3.13 匹配信息表2.3.14 缴纳信息表3、数据库的创建3.1数据库的建立CREATE DATABASE teachingON(NAME=teaching,FILENAME=‘D:\sql_data\teaching.mdf ‘,SIZE=10MB,MAXSIZE=50MB,FILEGROWTH=10% )LOG ON(NAME=teaching_log,FILENAME=‘D:\sql_data\teaching_log.ldf ‘,SIZE=2MB,MAXSIZE=5MB,FILEGROWTH=1MB )3.2数据表的创建1、用户信息表的创建create table Users(User_id numeric(6)identity not null primary key, User_name varchar(8) not null unique,User_pwd varchar(16) not null,Type char(6) null default('学员'))2、学员信息表的创建create table Student(Sno numeric(6)identity not null primary key,Suser_id numeric(6) not null constraint S_Fore foreign key references Users(User_id),Sname varchar(8) not null,Ssex char(2) null default('男'),Birthday smalldatetime not null,Town varchar(10) not null,Other varchar(20) null,Phone numeric(11) not null,Pname varchar(8)not null,School varchar(15) not null,Grade varchar(10) not null,Study varchar(300) null)3、教员信息表的创建create table Teacher(Tno numeric(6)identity not null primary key,Tuser_id numeric(6) not null constraint T_Fore foreign key references Users(User_id),Tname varchar(8) not null,Tsex char(2) null default('男'),Birthday smalldatetime not null,Photo image null,Phone numeric(11) not null,Station varchar(10) null default('在校教师'),Introduction varchar(300) not null,Degree varchar(6) not null,School varchar(15)null,Major varchar(15)null)4、课程信息表的创建create table Course(Cno char(6)not null primary key,Cname varchar(10)not null unique)5、学员/教员课程信息表的创建create table STC(STCno numeric(6)identity not null primary key,User_id numeric(6) not null constraint STC_id_Fore foreign key references Users(User_id),Cno char(6) not null constraint STC_cno_Fore foreign key references Course(Cno),Money money not null,Day varchar(5) not null,Start_time datetime null,End_time datetime null)6、教授情况表的创建create table Jiaoshou(Jno numeric(6)identity not null primary key,Sno numeric(6) not null constraint J_Sno_Fore foreign key references Student(Sno),Tno numeric(6) not null constraint J_Tno_Fore foreign key references Teacher(Tno),Cno char(6) not null constraint J_Cno_Fore foreign key references Course(Cno),Ano numeric(6) not null constraint J_Ano_Fore foreign key references Agreement(Ano),Type varchar(6) null default('试教'))7、协议表的创建create table Agreement(Ano numeric(6)identity not null primary key,Content varchar(500) not null,Time datetime null,Limit datetime not null)8、公告信息表的创建create table Placard(Pno numeric(6)identity not null primary key,Title varchar(20) not null,Content varchar(300) not null,Time datetime null)9、服务反馈表的创建create table ServiceInfo(Sino numeric(6)identity not null primary key,User_id numeric(6) not null constraint SI_Fore foreign key references Users(User_id),Time datetime null,Mangyidu varchar(8)null default('非常满意'),Advice varchar(100) null)10、费用表的创建create table Fee(Fno numeric(6)identity not null primary key,Feetype varchar(10) not null,Price money not null)11、教学评价表的创建create table Evaluate(Eno numeric(6)identity not null primary key,Sno numeric(6) not null constraint E_Sno_Fore foreign key references Student(Sno),Tno numeric(6) not null constraint E_Tno_Fore foreign key references Teacher(Tno),Scale varchar(10) null default('非常好'),Remark varchar(100) null,Time datetime null)12、匹配信息表的创建create table Matching(Mno numeric(6)identity not null primary key ,Sno numeric(6) not null constraint M_Sno_Fore foreign key references Student(Sno),Tno numeric(6) not null constraint M_Tno_Fore foreign key references Teacher(Tno),Time datetime null,Limit datetime not null)12、缴纳信息表的创建create table Pay(Pno numeric(6)identity not null primary key,Sno numeric(6) not null constraint Pay_Sno_Fore foreign key references Student(Sno),Fno numeric(6) not null constraint Pay_Fno_Fore foreign key references Fee(Fno),Time datetime null,Remark varchar(100) null,Way varchar(10) not null)。