《数据库系统概念》第1-3章知识点总结
数据库:由一个互相关联的数据的集合和一组用以访问这些数据的程序组成。
元组:指代行
属性:指代列
在文件处理系统中存储组织信息的主要弊端:
(1)数据的冗余和不一致
(2)数据访问困难
(3)数据孤立
(4)完整性问题
所以我们要有数据库
数据结构的基础是数据模型
数据模型是一个描述数据、数据联系、数据语义以及一致性约束的概念工具集合。主要模型有以下四种:
(1)关系模型,relational model
(2)实体-联系模型,entity-relationship model
(3)基于对象的数据模型,object-based data model
(4)单结构化数据模型,semistructured data model;例如可扩展标记语言(XML)被广泛地用来表示半结构化数据
实体-联系模型
实体集:用矩形框表示,实体名在头部,属性名列在下面
联系集:用连接一对相关的实体集的菱形表示,联系名放在菱形内部
下面是一个例子:
row:行
column:列
record/taple:元组
attributes:属性(就是每一列)
domain:域,For each attribute of a relation ,there is a set of permitted values ,called the domain of that attribute.
atomic:原子性,For all relations r ,the domains of all attributes of r be atomic.
null:空,The null value is a special value that signifies that the value is unknown or does not exist.
database schema:数据库模式,is the logical design of the database.
database instance:数据库示例,is a snapshot of the data in the database at a given instant in time.
superkey:超码,is a set of one or more attributes that ,taken collectively ,allow us to identify uniquely a tuple in the relation.
candidate keys:候选码,the minimal superkeys are called candidate keys.
primary key:主码,one of the candidate keys is selected to be the primary key
foreign key:外码,a relation ,say r1 ,may include among its attributes the primary key of another relation ,say r2 .This attribute is called a foreign key form r1 ,referencing r2 .
referencing relation:外码依赖的参照关系,the relation r1 is called the referencing relation of the foreign key dependency
referenced relation:外码的被参照关系,r2 is called the referenced relation of the foreign key
超码:一个或多个属性的集合,这些属性的组合可以使我们在一个关系中唯一地表示一个元 组
候选码:最小超码。因为超码中可能包含无关紧要的属性,候选码中不存在无关紧要的属性。
主码:用来在一个关系中区分不同元组的候选码,应该选择那些值从不或极少变化的属性。 主码属性一般列在其他属性前面,且有下划线
外码:一个关系模式(如r1)可能在它的属性中包括另一个关系模式(如r2)的主码。这 个属性在r1上称作参照r2的外码。关系r1也称为外码依赖的参照关系,r2叫做外码 的被参照关系。
数据库中的常用的关系代数
初级SQL
The SQL language has several parts:
(1)Data_definition language(DDL,数据定义语言)
①defining relation schemas(定义关系模式)
②deleting relations(删除关系)
③modifying relation schemas(修改关系模式)
(2)Data_manipulation language(DML,数据操纵语言)