ordered tuple이기 때문에 순서를 바꿀 수 없다. 즉 order of attribute values matter
r(R)
Table / set of tuples/rows
r(R) = {t1, t2, …, tn} where each ti is an n-tuple
Here, ti = <v1, v2, …, vn> where each vj element of dom(Aj)
A specific state/value/population of relation R
Terminology Summary
Relational Integrity Constraints
Basic operations for changing the database
INSERT : a new tuple
DELETE : an existing tuple
MODIFY : an existing tuple
해당 operation에 의해서 database의 state가 변화가 된다는 점을 기억해야 한다.
예를 들어 employee의 address가 달라지면 supervisor가 달라지게 된다.
Basic Idea : Constraints are conditions that must hold on all valid states (after every INSERT, UPDATE, DELETE)
3 types of constraints
Key constraints
Entity integrity constraints
Referential integrity (Foreign Key) constraints
Key Constraints
If a relation has several candidate keys, one is chosen arbitrarily as a primary key
→ The primary-key value is used to uniquely identify each tuple in a relation
예를 들어 Texas ABC-739를 또 추가하려는 query를 날린 경우 해당 query를 reject하는 것이다.
General rule : Choose as primary key the smallest of the candidate keys (in terms of size)
💡
컴퓨터 architecture 관점으로 보면 더 작은 data size에 해당하는 것을 데려오는 것이 더 유리하다. 따라서 일반적으로 data size가 클수록 더 inefficient하기 때문에 더 적은 data size에 해당하는 것을 primary key로 설정하는 것이다.
Entity Integrity Constraints
The primary key attributes can’t be null
Primary key values are used to identify the individual tuples
If PK has several attributes (i.e. composite PK), null is not allowed in any of these attributes
Referential Integrity Constraints
Referential Integrity/Foreign key constraints: the value in the FK column can be either
a value of an existing PK value from another relation