主鍵、超鍵、候選鍵、外鍵定義;三種約束;ER圖舉例;資料庫相關鏈接 ...
資料庫複習③
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圖練習題鏈接:http://www.cnblogs.com/zpfbuaa/p/5256187.html
資料庫知識點①~⑤鏈接:http://www.cnblogs.com/zpfbuaa/p/5358035.html
資料庫複習鏈接①~待更新:http://www.cnblogs.com/zpfbuaa/p/5585349.html
資料庫基礎知識考題鏈接:http://www.cnblogs.com/zpfbuaa/p/5442113.html