北邮国院EBU5602数据库DataBase期末复习,包含所有章节

前提:想起总结这个东西已经距离考试结束很久了,笔记很多细节描述的不太清晰,很多地方也忘记了,有问题的地方也欢迎大家及时提出来!!

目录:

• Block 1

– Introduction 介绍

– Relationalmodel 关系模型

– RelationalAlgebra 关系代数

– Entity Relationship(ER) modelling 实体关系建模

• Block 2

– EER modelling 强化实体关系建模

– ER toRelational Model mapping ER与EER建立关系模型图

– SQL 语言

– Database design

• Block 3

– Normalization

– AdvancedNormalization

– Transactionmanagement

• Block 4

– DistributedDBMS

– XML

– NoSQL

DreamHome举例:是一个书中的关系模型,老师的课程中和平时的举例中很多都是使用的这个关系模型


Block 1

Introduction


Relational Model and Relational Algebra

基础知识:

• Relation(关系): A relation is a table with columns and rows. 包含行和列的表

• Attribute(属性):An attribute is a named column of a relation. 关系的命名列

• Domain(域): the set of allowable values for one or more attributes. 一个或多个属性的允许值集

• Tuple(元组): A tuple is row of a relation. 关系的行

• Degree(度): the number of attributes in a relation. 关系中属性的数量

• Cardinality(基数): the number of tuples in a relation. 关系中的元组数

• Relational database(关系数据库): A collection of normalized relations with distinct relation names

Relational keys(关系键)重要!!!

Candidate Key 候选键(考试必考的东西,一定要掌握,PS:虽然理解起来有点困难)

– A set of attributes that uniquely identifies a tuple within arelation.

– Uniqueness : In each tuple, candidate key uniquely identify thattuple.

– Irreducibility: No proper subset of the candidate key has theuniqueness property.

可唯一标识某一元组的属性组,属性组中各个属性缺一不可。【t_student】(学号,姓名,学院),姓名可能会重复,所以其中学号可以唯一标识一条记录,学号就是t_student的候选键。那么假设姓名不会重复,那么候选键就有学号和姓名两个。又比如【t_grade】(学号,课程,成绩),其中一个学生可以有多条成绩记录,所以需要学号和课程号组合才可以唯一标识一条数据库记录,所以学号、课程号就是t_student的一个候选键。

Primary Key 主键

– Candidate key selected to identify tuples uniquely with in relation.

只要一个属性组可以唯一标识一个元组,那么就说这个属性组是超键 【t_student】(学号,姓名,学院),姓名可能会重复,所以(学号)是一个超键同时也是候选键,(学号,姓名)可唯一标识一个元组,所以其也是超键,但不是候选键,因为少了姓名也可以唯一标识。

• Foreign Key 外键

– Attribute, or set of attributes, within one relation that matches candidate key of some other(possibly same) relation.

对于Domains的举例:


一些关于关系代数的练习题

Block 2

Block 3

Block 4

由于期末比较紧张,Block4的部分总结的不是很全,详细内容还是参考一下老师的ppt吧

需要总结的pdf文件可以私信我

  • 22
    点赞
  • 74
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
这段代码有几个问题需要优化: 1. 如果其中一个文件读取失败,整个方法就会返回并且数据无法正确导入,应该在每个文件读取失败后继续读取其他文件。 2. 在读取文件时,最好使用绝对路径,因为相对路径可能会因为不同的执行环境而不同。 3. 在解析文件内容时,最好检查文件内容的行数是否相等,否则会导致数据不匹配。 以下是优化后的代码: ``` public void importData() { List<String> files = Arrays.asList("courses.txt", "scores.txt", "credits.txt", "semesters.txt", "types.txt"); List<List<String>> fileContents = new ArrayList<>(); for (String file : files) { try (Stream<String> stream = Files.lines(Paths.get("F:/ProgramData/IdeaProjects/BUPT-EBU6304G49-main/SE0514/src/data/" + file), StandardCharsets.UTF_8)) { fileContents.add(stream.collect(Collectors.toList())); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Failed to import data from file: " + file); } } if (fileContents.size() != 5) { JOptionPane.showMessageDialog(null, "Failed to import data"); return; } // Check if each file has the same number of lines int numLines = fileContents.get(0).size(); for (List<String> content : fileContents) { if (content.size() != numLines) { JOptionPane.showMessageDialog(null, "Failed to import data: files do not have the same number of lines"); return; } } // Clear current data this.courses.clear(); // Read data from files and add to list for (int i = 0; i < numLines; i++) { String course = fileContents.get(0).get(i); String score = fileContents.get(1).get(i); String credit = fileContents.get(2).get(i); String semester = fileContents.get(3).get(i); String courseType = fileContents.get(4).get(i); addData(course, credit, score, semester, courseType); this.courses.add(new Course(course, score, credit, semester, courseType)); } JOptionPane.showMessageDialog(null, "Data has been imported"); } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值