Relational Model Concepts
Database: relations(tables)의 모음
Relation: tuples(rows)의 집합
Tuple: 실 세계에 존재하는 Entity 또는 Relationship을 표현하기 위한 것으로, attribute로 구성된다.
Attribute: tuple와 대응되는 객체의 특징을 표현하기 위한 것
Domain D: 더 이상 쪼개지지 않는 atomic한 value들의 집합
Attribute A_i: Domain이 relation 스키마에서 어떤 역할을 하는 지에 대한 이름, dom(A_i)는 relation schema에서 A_i의 Domain
Relation schema R: relation 이름과 다수의 attribute로 이루어진 것. R(A_1,A_2,...,A_n) 으로 표기됨.
Tuple t of relation R: n-tuple이라고도 불리며, t = <v_1, v_2, ..., v_n> 의 ordered list로 표현된다. 각각의 v_i는 dom(A_i)에 속하는 값이다.
Relation instance r(R): relation schema R을 따르는 tuple들의 집합. r(R) = {t_1, t_2, ..., t_m}으로 표기된다. r(R)는 모든 Attribute domain의 Cartesian product의 부분집합이다.
Characteristics of Relations
- 튜플간 순서는 의미가 없다.
- 튜플은 ordered list이지만, 순서가 그렇게 중요하지 않다. 함숫값처럼 attribute의 값에 접근(t_i[A_j])하기 때문이다.
- tuple에 있는 각 attribute 값은 쪼갤 수 없는 atomic한 value이다. composite attribute와 multi-valued attribute를 취급하지 않는다.
- attribute 값은 NULL일 수 있는데, 이는 그 값이 알려지지 않거나, 사용될 수 없는 값임을 의미한다.
- t[A_i]는 tuple t가 가지고 있는 Attribute A_i의 값인 v_i를 참조하려는 것이다. t[A_u, A_w, ... , A_z] 처럼 여러 Attribute 값에 접근할 수도 있다.
Relational Model Constraints
Constraints: relation schema에 있는 실제 값에 대한 제약사항으로, 모든 r(R)은 이를 따라야한다. 이는 mini-world의 rule로 부터 도출된다.
Key Constraint
Superkey: entity를 unique하게 식별하게 해주는 attribute의 집합. relation instance에서 서로 다른 어느 두 tuple도 서로 superkey 값이 같아선 안된다.
Candidate key: Superkey인 attribute 집합에서 임의의 attribute를 제외항 경우, 그 집합이 더 이상 superkey가 아니게 된다면, 그 집합을 Candidate key(Minimal superkey)라고 한다.
Key constraint: relation schema는 적어도 하나의 Candidate key를 가져야 한다. 이는 database designer가 결정한다.
Entity integrity constraint
Relational database schema: 같은 database에 속하는 relation schema의 집합. S = {R_1, R_2, ..., R_m}로 표현한다. 이는 integrity constraints를 포함한다.
Relational database instance: 같은 database에 속하는 relation instance의 집합. {r_1, r_2, ..., r_m}
Entity Integrity Constraints: r{R)에서 모든 tuple의 PK값은 NULL이 될 수 없다.
Referential integrity constraint
- 두 relation 간의 구체적 제약사항, relation에 있는 두 tuple간 일관성을 유지하지 위해 사용된다.
- 한 relation에 있는 tuple은 다른 relation에 존재하는 tuple을 참조해야한다.
- Foreign key (FK): 참조되는 튜플의 PK 값을 attribute로 갖는 것, NULL일 수 있다. t_1[FK] = t_2[PK] (or NULL) <- t_1이 t_2를 참조
'Computer Science > Database Systems' 카테고리의 다른 글
[Database Systems] Relational algebra (0) | 2025.01.28 |
---|---|
[Database Systems] ER to Relational model (0) | 2025.01.26 |
[Database Systems] ER Diagram (0) | 2025.01.11 |
[Database Systems] Requirements (0) | 2025.01.08 |
[Database Systems] Data, Schema, Data independent (0) | 2025.01.05 |