数据库复习③

数据库复习③

2016年6月15日

15:24

Main ER Model ER模型

1. ER模型中的约束constraints有哪些?

   Single value constraints 单值约束

    EX:  a person can have only one father.

  Referential integrity constraints 引用完整性约束

    EX: if you work for a company, it must exist in the database

  Domain constraints 域约束

    EX: peoples’ ages are between 0 and 150.

2.ER图中的各种键Keys概念

   super key 超键

     A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity

    在关系中能唯一标识元组的属性集称为关系模式的超键

  candidate key  候选键

    A candidate key of an entity set is a minimal super key

    不含有多余属性的超键称为候选键

    举例:Customer_id is candidate key of customer

  primary key 主键

     Although several candidate keys may exist, one of the candidate keys is selected to be the primary key

    用户选作元组标识的一个候选键程序主键

  Foreign key 外键

    完整性约束的一种,要求该属性在另一表的某个key中出现。

3.弱实体集Weak Entity Sets

  From https://en.wikipedia.org/wiki/Weak_entity

  In a relational database, a weak entity is an entity that cannot be uniquely identified by its attributes alone; therefore, it must use a foreign key in conjunction with its attributes to create a primary key. The foreign key is typically a primary key of an entity it is related to.

4.ER模型的原则

  • 避免冗余Avoid redundancy
  • 限制弱实体集的使用Limit the use of weak entity sets.
  • 如果选为属性时是时不要使用实体集Don’t use an entity set when an attribute will do.

5.好的ER图举例:

 

6.差的ER图举例:

7.ER图举例:

 

数据库复习④摘要: 关系模型与ER模型、Database & Schema & Instance

ER图练习题链接:http://www.cnblogs.com/zpfbuaa/p/5256187.html 

数据库知识点①~⑤链接:http://www.cnblogs.com/zpfbuaa/p/5358035.html

数据库复习④:http://www.cnblogs.com/zpfbuaa/p/5589353.html

数据库基础知识考题链接:http://www.cnblogs.com/zpfbuaa/p/5442113.html

原文地址:https://www.cnblogs.com/zpfbuaa/p/5587951.html