《图书管理系统数据库设计报告》.doc
文本预览下载声明
《SQL Server 2000 实用教材》
实
验
报
告
学生_成绩数据库students_score
实验目的
通过完成从用户需求分析,数据库设计到上机编程,调试和应用等全过程,进一步理解和掌握教材中的相关内容。
实验简介
在SQL Server 2000 中创建students_score数据库,并在students_score数据库内创建学生表、成绩表、课程表、授课表、教师表、班级表等,向各个表导入相应信息及记录,在SQL Server 2000的查询分析器和企业管理器实行查询、修改记录、删出信息、创建视图、创建触发器等操作来完成需求。
students_score数据库中的关系模式
学生表:id号、所在系、班级、学号(主键)、姓名、性别、出生日期
成绩表:id号(主键)、学号、课程编号、分数
课程表:id号、课程编号(主键)、课程名称、学分
授课表:id号(主键)、授课课程编号、授课教师编号、开课时间、结课时间
教师表:id号、教师编号(主键)、教师姓名、所在系、性别、出生日期、工作时间
班级表:id号、班级(主键)、专业名称、班主任编号
students_score数据库中的关系图
students_score数据库表述信息
students_score数据库是用于记录学生信、教师信、课程、授课等信息的,此系统功能分为面向学生和面向教师两部分,可用于学校教学信息查询。面向学生部分可用于学生教学信息查询及信息管理,面向教师部分可用于教师教学信息查询和管理。
SQL 代码实现
1创建数据库和表
1.1创建数据库
create database students_score
on primary
(name=student_dat1,
filename=f:\cy\数据库\student_dat1.mdf,
size=5,
maxsize=25,
filegrowth=5
),
(name=student_dat2,
filename=f:\cy\数据库\student_dat2.ndf,
size=5,
maxsize=25,
filegrowth=5
)
log on
(name=student_log1,
filename=f:\cy\数据库\student_log1.ldf,
size=5,
maxsize=25,
filegrowth=5
),
(name=student_log2,
filename=f:\cy\数据库\student_log2.ldf,
size=5,
maxsize=25,
filegrowth=5
)
1.2创建表
(1)创建学生表
create table 学生表
(id bigint identity(1,1) not null,
所在系 varchar(30) not null,
班级 varchar(20) not null,
学号 varchar(10) not null primary key,
姓名 char(15) not null,
性别 char(10) not null,
出生日期 datetime not null,
)
(2)创建成绩表
create table 成绩表
(id bigint identity(1,1) not null primary key,
学号 varchar(10) not null,
课程编号 varchar(50) not null,
分数 int null,
)
(3)创建课程表
create table 课程表
(id bigint identity(1,1) not null,
课程编号 varchar(50) not null primary key,
课程名称 varchar(50) not null,
学分 int not null,
)
(4)创建授课表
create table 授课表
(id bigint identity(1,1) not null primary key,
授课教师编号 varchar(30) not null,
授课课程编号 varchar(50) null,
开课时间 datetime null,
结课时间 datetime null,
)
(5)创建教师表
create table 教师表
(id bigint identity(1,1) not null,
教师姓名 char(50) not null ,
教师编号 varchar(30) not null primary key,
所在系 varchar(50) not null,
性别 char(2) not null,
出生日期 datetime not
显示全部