热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

大学生竞赛管理系统项目

大学生竞赛管理系统设计一个学生可以参加多个学科竞赛,竞赛分为不同等级,按照重要性可以分为A类、B类和C类,学生可以多人组队参加一个比赛&

大学生竞赛管理系统设计

一个学生可以参加多个学科竞赛,竞赛分为不同等级,按照重要性可以分为 A 类、B类和 C 类,学生可以多人组队参加一个比赛,每个队可以有多个指导教师,竞赛成绩按照
获奖级别有国家级和省级,分为一等奖、二等奖、三等奖,每种竞赛每年都有相对固定的比赛时间、名称和主办机构。试设计一个大学生竞赛管理系统,能够完成对学生竞赛的管理,可以实现统计高校各个学院某个时间段内竞赛的参加和获奖情况,也可以统计每个同学或每个年级某个时间段内竞赛的参加和获奖情况。

(1)画出系统的 E-R 图,给出实体或联系的属性,标明联系的种类;
image

(2)写出关系模式;
学院(学院号,学院名称,成立时间)
专业(专业号,专业名称,学院号)
学生(学号,姓名,班级,专业号)
团队(团队编号,项目名称,团队名称,竞赛编号,获奖级别,获奖奖项,开始时间,获奖时间)
竞赛(竞赛编号,名称,主办方,等级,比赛月份)
老师(工号,姓名,职称)
团队指导(团队编号,工号)
团队组成(团队编号,学号)

(3)根据关系规范理论进行数据库的逻辑设计,给出数据库表的设计,数据库表设计格 式参照下面:

表 1 学院表(college)


字段名中文含义类型约束备注
collegekey学院号int主键
name学院名称char(30)not null
collegetime成立时间datenull

表 2 专业表(major)


字段名中文含义类型约束备注
majorkey专业号char(6)主键
majorname专业名称varchar(30)null
collegekey学院号intnull外键,参照college表的collegekey

表 3 学生表(student)


字段名中文含义类型约束备注
stid学号char(6)主键
sname姓名char(20)null
class班级char(20)null
majorkey专业号char(6)null外键,参照major表的majorkey

表 4 团队表(team)


字段名中文含义类型约束备注
teamid团队编号int主键
pname项目名称varchar(30)null
tname团队名称varchar(30)null
cid竞赛编号intnull外键,参照competeinfo表的cid
stime开始时间datenull
pgrade获奖级别char(10)null
pburse获奖奖项char(10)null
ptime获奖时间datenull

表 5 老师表(teacher)


字段名中文含义类型约束备注
tid工号char(6)主键
tname姓名char(20)null
title职称char(20)null

表 6 竞赛表(competeinfo)


字段名中文含义类型约束备注
cid竞赛编号int主键
cname竞赛名称varchar(100)not null
cunit主办方varchar(100)not null
cgrade竞赛等级char(1)not null取值为A、B、C中一个
cmonth比赛月份char(2)null

表 7 团队指导表(directioninfo)


字段名中文含义类型约束备注
teamid团队编号int外键,参照team表的teamidteamid和tid联合作为主键
tid工号char(6)外键,参照teacher表的tid

表 8 团队组成表(componentinfo)


字段名中文含义类型约束备注
teamid团队编号int外键,参照team表的teamidteamid和stid联合作为主键
stid学号char(6)外键,参照student表的stid

(5)在 Sql server 数据库中创建数据库 test 并创建相应的数据库表;
(6)可以通过导入文件的方式在数据库表中输入若干条数据;
通过SQL Server导入各表数据:
在sql server中创建bigtest数据库,使用如下语句进行数据库建表
CREATE TABLE college(
collegekey int primary key,
name char(30) not null,
collegetime date null
)
CREATE TABLE major(
majorkey char(6) primary key,
majorname varchar(30) null,
collegekey int null references college(collegekey)
)

CREATE TABLE student(
stid char(6) primary key,
sname char(20) null,
class char(20) null,
majorkey char(6) null references major(majorkey)
)

CREATE TABLE team(
teamid int primary key,
pname varchar(30) null,
tname varchar(30) null,
cid int null references competeinfo(cid),
pgrade char(10) null,
pburse char(10) null,
ptime date null
)

CREATE TABLE teacher(
tid char(6) primary key,
tname char(20) null,
title char(20) null
)

CREATE TABLE competeinfo(
cid int primary key,
cname varchar(100) not null,
cunit varchar(100) not null,
cgrade char(1) not null check (cgrade in (‘A’,‘B’,‘C’)),
cmonth char(2) null,
)

CREATE TABLE directioninfo(
teamid int references team(teamid),
tid char(6) references teacher(tid),
primary key(teamid,tid)
)

(7)自己构造若干 SQL 语句,完成对数据库的调用、并实现题目所给统计要求,SQL 语 句至少为 10 条,要求自定义功能要求,并给出 SQL 语句结果,包括下面的语句:
create table 、create index 、 create view 、 select 语句 (至少 3 条,要把子句用上, 包括 from 子句、where 字句、group by 子句、having 字句、order by 子句)、insert 语句、 delete 语句、update 语句、grant 语句

create index语句:
把student表中按学号升序和班级降序的建立索引
create index studentindexs
on student(stid asc,class desc)
把team表中按竞赛号降序建立索引
create index team_index
on team(cid desc)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-k3BOwzhm-1634533483137)(https://user-images.githubusercontent.com/60837761/103448825-1000c700-4cda-11eb-9098-94173e545f5b.png)]

create view语句:
创建一个视图Viewprize,统计人工智能学院不同专业国家级、省级的获奖总数量
create view Viewprize
as
select college.name,pgrade,major.majorname,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid = componentinfo.teamid
and componentinfo.stid = student.stid
and student.majorkey = major.majorkey
and major.collegekey = college.collegekey
and college.name =‘人工智能与数据科学学院’
group by college.name,majorname,pgrade
having pgrade <> ‘NULL’
image

insert语句&#xff1a;
插入一条学生数据
insert student
values(‘151020’,‘张杰’,‘计141’,‘080901’)

image

插入一条团队数据
insert team values(26,‘面向未来的系统’,‘未来’,16,‘2019/8/29’,NULL,NULL,NULL)
image
image

delete语句&#xff1a;
删除学号为151020的student信息
delete student
where stid &#61; ‘151020’;

删除“面向未来的系统”队名的team信息
delete team
where pname &#61; ‘面向未来的系统’

update 语句
更新“未来1”队的指导老师
update directioninfo
set tid &#61; (
select tid
from teacher
where teacher.tname &#61; ‘孙盼’
)
where teamid &#61; (
select teamid
from team
where team.tname &#61; ‘未来1’
)

grant 语句
创建团队管理员角色&#xff0c;对team表有查找更新插入权限&#xff0c;创建用户&#xff0c;分配团队管理员角色
create login zzy with password &#61; ‘abc’,default_database &#61; bigtestnew
create user zzy for login zzy

create role team_manager
grant select,insert,update
on team
to team_manager

exec sp_addrolemember ‘team_manager’,‘zzy’
image
image
image

select语句&#xff1a;
查询未来1队的指导老师信息
select *
from teacher,directioninfo
where directioninfo.tid &#61; teacher.tid
and directioninfo.teamid &#61;
(select teamid
from team
where team.tname &#61; ‘未来’)

查询计算机科学与技术专业的团队参加获奖情况
select cname,cgrade,pname,pgrade,pburse,student.stid,student.sname
from team,componentinfo,student,competeinfo
where team.teamid &#61; componentinfo.teamid
and componentinfo.stid &#61; student.stid
and competeinfo.cid &#61; team.cid
and student.majorkey &#61; (select majorkey
from major
where major.majorname &#61; ‘计算机科学与技术’)
and pgrade !&#61; ‘NULL’
group by cgrade,cname,pgrade,pburse,student.stid,
student.sname,team.pname

统计人工智能与数据科学学院的省级获取情况
select cname,cgrade,pname,pgrade,pburse,student.stid,student.sname
from team,componentinfo,student,competeinfo,major
where team.teamid &#61; componentinfo.teamid
and componentinfo.stid &#61; student.stid
and competeinfo.cid &#61; team.cid
and student.majorkey &#61; major.majorkey
and major.collegekey in (select collegekey
from college
where college.name &#61; ‘人工智能与数据科学学院’)
group by cgrade,cname,pgrade,pburse,student.stid,
student.sname,team.pname
having pgrade <> ‘国家级’ and pgrade !&#61; ‘NULL’

统计不同学院的专业的竞赛获奖情况
select college.name,pgrade,major.majorname,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid &#61; componentinfo.teamid
and componentinfo.stid &#61; student.stid
and student.majorkey &#61; major.majorkey
and major.collegekey &#61; college.collegekey
group by college.name,majorname,pgrade
having pgrade <> ‘NULL’
order by num

(9)对于复杂的报表查询逻辑处理和自定义完整性&#xff0c;使用存储过程或触发器来完成。
1.查询学院不同年份&#xff0c;不同月份&#xff0c;各专业省级、国家级竞赛获奖总人数&#xff0c;各学院的省级获奖情况&#xff0c;各学院的国家级获奖情况&#xff0c;学校获奖省级总人数&#xff0c;学校获奖国家级总人数。
GO
create proc proc_include
&#64;syear int,&#64;date_begin int,&#64;date_end int
as
declare &#64;s_totalnumber int ,&#64;g_totalnumber int
begin

print(‘学院各专业省级、国家级竞赛获奖总人数’)
select college.name,pgrade,major.majorname,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid &#61; componentinfo.teamid
and componentinfo.stid &#61; student.stid
and student.majorkey &#61; major.majorkey
and major.collegekey &#61; college.collegekey
and year(ptime) &#61; &#64;syear
and month(ptime)>&#64;date_begin
and month(ptime)<&#64;date_end
group by college.name,majorname,pgrade
having pgrade <> ‘NULL’
order by num

print(‘各学院的省级获奖情况’)
select college.name,pgrade,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid &#61; componentinfo.teamid
and componentinfo.stid &#61; student.stid
and student.majorkey &#61; major.majorkey
and major.collegekey &#61; college.collegekey
and year(ptime) &#61; &#64;syear
and month(ptime)>&#64;date_begin
and month(ptime)<&#64;date_end
group by college.name,pgrade
having pgrade <> ‘NULL’ and pgrade <> ‘国家级’

print(‘各学院的国家级获奖情况’)
select college.name,pgrade,COUNT(pgrade) as num
from team,componentinfo,student,major,college
where team.teamid &#61; componentinfo.teamid
and componentinfo.stid &#61; student.stid
and student.majorkey &#61; major.majorkey
and major.collegekey &#61; college.collegekey
and year(ptime) &#61; &#64;syear
and month(ptime)>&#64;date_begin
and month(ptime)<&#64;date_end
group by college.name,pgrade
having pgrade <> ‘NULL’ and pgrade <> ‘省级’

select &#64;g_totalnumber &#61; COUNT(pgrade)
from team
where year(ptime) &#61; &#64;syear
and month(ptime)>&#64;date_begin
and month(ptime)<&#64;date_end
and pgrade <> ‘NULL’ and pgrade <> ‘省级’

select &#64;s_totalnumber &#61; COUNT(pgrade)
from team
where year(ptime) &#61; &#64;syear
and month(ptime)>&#64;date_begin
and month(ptime)<&#64;date_end
and pgrade <> ‘NULL’ and pgrade <> ‘国家级’

print(‘学校获奖省级总人数&#xff1a;’)
print &#64;s_totalnumber
print(‘学校获奖国家级总人数&#xff1a;’)
print &#64;g_totalnumber
end
image
image
image


推荐阅读
  • Nginx使用(server参数配置)
    本文介绍了Nginx的使用,重点讲解了server参数配置,包括端口号、主机名、根目录等内容。同时,还介绍了Nginx的反向代理功能。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • 本文介绍了Redis的基础数据结构string的应用场景,并以面试的形式进行问答讲解,帮助读者更好地理解和应用Redis。同时,描述了一位面试者的心理状态和面试官的行为。 ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • 本文介绍了游标的使用方法,并以一个水果供应商数据库为例进行了说明。首先创建了一个名为fruits的表,包含了水果的id、供应商id、名称和价格等字段。然后使用游标查询了水果的名称和价格,并将结果输出。最后对游标进行了关闭操作。通过本文可以了解到游标在数据库操作中的应用。 ... [详细]
  • 本文介绍了在Vue项目中如何结合Element UI解决连续上传多张图片及图片编辑的问题。作者强调了在编码前要明确需求和所需要的结果,并详细描述了自己的代码实现过程。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 基于layUI的图片上传前预览功能的2种实现方式
    本文介绍了基于layUI的图片上传前预览功能的两种实现方式:一种是使用blob+FileReader,另一种是使用layUI自带的参数。通过选择文件后点击文件名,在页面中间弹窗内预览图片。其中,layUI自带的参数实现了图片预览功能。该功能依赖于layUI的上传模块,并使用了blob和FileReader来读取本地文件并获取图像的base64编码。点击文件名时会执行See()函数。摘要长度为169字。 ... [详细]
  • 【MicroServices】【Arduino】装修甲醛检测,ArduinoDart甲醛、PM2.5、温湿度、光照传感器等,数据记录于SD卡,Python数据显示,UI5前台,微服务后台……
    这篇文章介绍了一个基于Arduino的装修甲醛检测项目,使用了ArduinoDart甲醛、PM2.5、温湿度、光照传感器等硬件,并将数据记录于SD卡,使用Python进行数据显示,使用UI5进行前台设计,使用微服务进行后台开发。该项目还在不断更新中,有兴趣的可以关注作者的博客和GitHub。 ... [详细]
  • 本文详细介绍了MySQL表分区的创建、增加和删除方法,包括查看分区数据量和全库数据量的方法。欢迎大家阅读并给予点评。 ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
  • Linux环境变量函数getenv、putenv、setenv和unsetenv详解
    本文详细解释了Linux中的环境变量函数getenv、putenv、setenv和unsetenv的用法和功能。通过使用这些函数,可以获取、设置和删除环境变量的值。同时给出了相应的函数原型、参数说明和返回值。通过示例代码演示了如何使用getenv函数获取环境变量的值,并打印出来。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
author-avatar
aaaaaaaaaaa的美丽人生_556
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有