| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
- Volatile
- spring security
- OAuth 2.0
- builder
- factory
- Dependency Injection
- 일급 컬렉션
- synchronized
- Spring
- 일급 객체
- lombok
- Google OAuth
- java
- Today
- Total
HJW's IT Blog
Database: 2주 본문
Chapter 5: The Relational Data Model and Relational Database Constraint
> Relation: table of values (어떤 값들의 표)
>> 행과 열

> Domain: atomic value의 집합 { 더 나누어 질 수 없는 값들}
ex) phone numbers, names, age
>> Domain 은 이름, 데이터 타입, 형식이 주어진다
> Relation Schema : Relation 의 구조만 간단히 보여주는 형식 R(A1, A2, ... , An)


>> Ai: R 내에 있는 특정 domain 의 역할의 이름
# n: 차수 (number of attributes)
> r(R): n-tuple ti 들의 집합 : r = {t1,t2, ... , tm}
> n - tuple t 는 n 개의 값으로 이루어진 tuple

> R( A1, A2, ... , An) 의 relation 이 있을때,,,
>>

>> R: Schema of the Relation
>> r(R): 특정 값
>> R: intension of relation
>> r: extension of relation
>> 2 개의 집합의 product 는 가능한 모든 경우의 수
>> Cardinality: 튜플의 수

> Relation 의 특성
>> tuple 은 순서가 없다
>> R(A1,A2,...,An) 의 속성과, t = <v1,v2,...,vn> 의 값은 순서가 있다고 생각
>> Tuple 이란 {<attributes> , <Value>} 의 집합
>> 모든 값은 atomic 한 값으로 간주
# 복합적 /. multivalued attributes 는 not allowed
# Flat Relational Model , First Normal Form assumption
>> NULL -> 모르거나, 해당사항 없다거나, 적용 불가능 (ex. 미혼인 사람의 결혼날짜)
> Relational Model 의 제약조건
>> 내재적 제약조건
# 데이터 모델에 내재된 제약조건 ( ex. tuple 의 duplication 불가능)
# 스키마 제약조건: 명시된 제약조건
- Key 제약조건
- NULL에 대한 제약조건
- Entity 에 내제된 제약조건
- Referential integrity constraints (참조관계)
- Domain Constraints
-> 값에 대한 제약조건으로, atomic 이어야 함
-> Data Types
-> Subrange of values
-> Enumerated data type
- Data Dependencies
- Key Constraints
-> Relation 이란 tuple 의 집합
-> SuperKey of R : Set of attributes of R
-> t1 & t2 tuple 에 대해 t1[SK] != t2[SK]
-> Minimal superkey : 하나라도 제거하면, unique 하지 않다

-> ex superkey) {SSN, Name, Age} ~ SSN 을 뺀다면 unique 하지 않다
-> Candidate Key
-> Relation Schema 는 하나 이상의 key 를 가질 수 있다
-> Primary Key: 기본 key with single attributes

# Application 제약조건
- Business Rules
> Relational DBs and Relational DB Schemas
>> Relational Database Schema S
# Relational 스키마와 이에 해당하는 무결성 제약조건의 집합
>> Relational Database State DB of S
#Relation States DB = {r1, r2, ... , rn}
# 각 ri 는 Ri 의 state
> Entity Integrity
>> Primary Key 는 NULL 일 수 없다 -> Identifier 이기 때문
>> Primary Key 가 아니라고 NULL 을 허용하지 않을 수 있다.
> Referential Integrity
>> 두개의 Relation 의 튜플들 간의 관계를 나타낸다
>> Referenced relation(참조 당하는) 과 referencing relation(참조 하는)
# Foreign Key attribute
> Foreign Key 는 다음사항을 만족시킨다
>> R1 의 FK 는 R2 의 PK 와 같은 domain 이다
>> Tuple t1은 둘중 한가지 경우여야 한다
# R2의 현제 state 에 있는 PK 값과 같아야 하거나
# NULL
> UPDATE 와 Constraint Violation handling
>> 두가지 카테고리의 동작이 있다
# Retrievals
# Updates ( INSERT, DELETE, MODIFY)
>> Violation Handling
# Cancel the operation
# 실행 but inform user of violation
# Trigger additional updates so violation is corrected
# Execute a user - specified error - correction routine