数据库一阶段学习
# 1、考试介绍
数据库的考点一般在51~56题
# 2、结构数据模型
# 2.1、层次模型
# 2.2、网状模型
# 2.3、关系模型
关系模型式一种二维表格结构来实现实体以及实体之间联系的数据模型。
# 2.4、例题
# 3、数据库的三级模式结构
三级模式
- 外模式(视图)
- 模式(基本表)
- 内模式(数据库存储文件)
# 4、两级映像
- 数据的物理独立性:概念模式和内模式之间的映像
- 数据的逻辑独立性:外模式和概念模式之间的映像
# 4.1、例题
# 5、关系模型种的基本术语
下图的关系模式为S(Sno,Sname,SD,Sage,Sex)
# 6、关系模型的定义
- 关系模型中数据的逻辑关系式一张二维表
- 关系模型操作又:选中、投影、链接、除、并、交、差等查询操作和增加、删除操作等
# 7、关系完整性约束
# 8、笛卡尔积
# 9、传统的集合运算
# 10、选择、投影、连接
这个两个,自己去看视频
# 11、自然连接
# 12、外连接
# 13、例题
# 13、投影、选择转sql
# 14、笛卡尔积转sql语言
# 15、自然连接转sql
# 16、例题:
# 17、数据定义语言
、
# 18、where条件查询
select * from studentTabel where score between 30 and 90;
select * from studentTable where name like "罗%"
select * from studentTable where name like "罗__"
select * from studentTable where name not like "罗"
select * from studentTable where score in (90,91,92)
select * from studentTable where score not in (90,91,92)
select * from studentTable where name ="王芳" and sex = "女"
select * from student where name is not Null
# 19、排序查询
默认为升序
降序
select * from student where 性别='男' order by 班号 desc
升序
select * from student where 性别='男' order by 班号 asc
多个排序条件
select * from student where 性别='男' order by 班号 asc , 分数 asc
# 20、使用聚合函数
先将课程号去重,然后在进行一个统计
# 21、数据分组
# 22、表的连接查询
select * from student inner join score on student.'学号' = score.'学号'
select student.姓名,score.课程号,socre.分数 from student ,score where student.'学号' = score.'学号'