A. Oracle创建学生选课数据库。完成下列要求:
学生表 student
课程表 course
学生选课关系表 stucourse
create table student(sno number primary key,sname varchar2(20));
insert into student values(1,'alley');
insert into student values(2,'bob');
commit;
create table course(cno number primary key,cname varchar2(20));
insert into course values(1,'语文');
insert into course values(2,'数学');
commit;
create table stucourse(sno number,cno number);
alter table stucourse add constraint pk_stucource primary key(sno,cno);
insert into stucourse values(1,1);
insert into stucourse values(1,2);
insert into stucourse values(2,1);
commit;
2. select a.sname,c.cname
from student a,stucourse b,coursec
where a.sno = b.sno and b.cno=c.no;
3. 查询选修一门以上的学生,按学号从小到大排序
select a.sno, a.sname
from student a,stucourse b,course c
where a.sno = b.sno and b.cno=c.no
group by a.sno,a.sname
having count(1)>=1
order by a.sno;
4、各用一条语句实现下列功能:添加表的列、更新表的某一字段值、删除表的列、删除表数据、修改表的名称。
alter table student add ssex varchar2(2);
update student set ssex='女';
alter table student drop column ssex;
delete from student where sno=1;
alter table student rename to studentnew;
5、在PL/SQL中执行SELECT语句:在某一实体表中,查询符合某一条件的记录,并显示相应的几个字段值
select sno, sname
from student
where sno=1;
6、用CASE语句实现一多分支结构
select case when sno=1 then '学号1‘ when sno=2 then '学号2' else '其他学号' end
from student;
B. 求Oracle设计的学生选课管理系统的数据库(包含SQL语句)
我理解楼主是要一个数据库的设计方案,其中包括相关SQL、逻辑关系、业务处理方法。
(Ps:偶平时工作就是做设计和开发的,以下所有SQL经过oracle测试)
学生表 Student:
学生ID(主键)、学生代码、学生名称、备用字段1、备用字段2、备用字段3;
课程表 Class:
课程ID(主键)、课程代码、课程名称、备用字段1、备用字段2、备用字段3;
MAPPING表 StuClass:
主键ID、学生ID、课程ID。
-- Create table student
create table student
(
studentid number(22),
studentcode varchar2(16),
studentname varchar2(16),
attr1 varchar2(64),
attr2 varchar2(64),
attr3 varchar2(64)
);
-- Create primary key constraints
alter table student
add constraint student_pk primary key (STUDENTID);
-- Create table class
create table class
(
classid number(22),
classcode varchar2(16),
classname varchar2(16),
attr1 varchar2(64),
attr2 varchar2(64),
attr3 varchar2(64)
);
-- Create primary key constraints
alter table class
add constraint class_pk primary key (CLASSID);
-- Create table stuclass
create table stuclass
(
stuclassid number(22),
studentid varchar2(16),
classid varchar2(16)
);
-- Create primary key constraints
alter table stuclass
add constraint stuclass_pk primary key (STUCLASSID);
系统初始化时录入主数据:学生信息、课程信息。
APP做业务处理:
1、学生选课程(单选或多选):insert into stuclass values(?,?,?);
2、查看所有学生选择的所有课程:
select s.studentcode,s.studentname,c.classcode,c.classname
from student s left join stuclass sc on s.studentid=sc.studentid
left join class c on sc.classid=c.classid order by s.studentid
(如查看某些学生或某个学生选择了哪些课程,可在后面加where条件)
3、查看所有课程有哪些学生选择:
select c.classcode,c.classname,s.studentcode,s.studentname
from class c left join stuclass sc on sc.classid=c.classid
left join student s on s.studentid=sc.studentid order by c.classid
(如查查看某些课程或某个课程有哪些学生选择,可在后面加where条件)
C. 按下列要求创建“学生选课数据库XX”数据库(XX为学生的学号),并为数据库创建三个基本表结构
(1)、select 学号,姓名,年龄 from Student order by 年龄 desc
(2)、select (select 课程名 from Course c where c.课程号=s.课程号) 课程名称, s.分数 from sc s
where s.学号=(select st.学号 from Student where 姓名='张三')
(3)、select 姓名 from Student where 学号 in ( select distinct 学号 from SC where 分数>=60 )
(4)、select Avg(年龄) from Student st where st.学号 in( select sc.学号 from sc sc where sc.课程号 in (select 课程号 from Course c where 课程名='101'))
and 性别='女'
(5)、select (select 姓名 from Student st where st.学号=sc1.学号) 学生姓名,sc1.分数 from SC sc1
where sc1.分数 in (select max(分数) from sc sc where sc.课程号 in (select 课程号 from Course c where c. 任课老师='张青'))
and sc.课程号 in (select 课程号 from Course c where c. 任课老师='张青')
(6)delete from SC s where s.分数<60
(7)update SC set 分数=avg(select 分数 from sc where 课程号='203') where 学号='105' and 课程号='203'
(8)create view over80 as
select sc1.学号,(select 姓名 from Student st where st. 学号=sc1.学号) 姓名,
sc1.课程号,(select 课程名 from Course c where c. 课程号=sc1.课程号) 课程名,(select 任课老师 from Course c where c. 课程号=sc1.课程号) 任课老师,
sc1.分数
from sc sc1 where sc1.分数>80
D. 做一个学生选课系统;但是数据库不知道怎么设计表;请帮忙看看!
第一种方法:设计2个表,一个学生信息表,一个选课记录表。关联学生ID.
选课记录
ID KCname XSID KCbs (主键ID)
序号 课程名称 选课学生身份证 课程标示(1,2,3)
也可以直接用汉字。查询应该会吧。
学生信息表
XSname XSID tel sex ( 主键XSID)
学生名称 学生身份证 电话 性别
第二种方法:用一张表
ID XSname XSID tel sex KCname KCbs (主键ID)
序号 学生名字 学生身份证 电话 性别 课程名字 课程标示
E. 学生选课系统数据库表设计
超链接不一样吗
F. 学生选课系统的数据库设计
先理清楚项目中有多少关联元素,再理清楚各元素的属性,最后才是规划数据库表
比如,你给出的情况下有以下这些元素:
学生
课程
教室
教师
学生有如下子元素:
基本情况
选修课程记录
学生-基本情况有如下属性:
学号,姓名,性别,民族,......
G. 1.设计一个选课数据库 CMS,并在MySQL中实现
学生表student:id,name (学生id和学生姓名)科目表courses:id,name (科目id和科目名称)选科表:sid,cid,result (学生id,科目id,成绩)例如:student1,张三2,李四courses1,语文2,数学3,英语1,1,901,2,802,1,882,2,902,3,85张三选了语文和数学,李四选了语文数学英语,假如一个学生没有选课,那么他不会出现在成绩表中(成绩可以为空,不一定现在就有成绩)