티스토리 뷰

개념/데이터베이스시스템

Relational Model

상어악어 2022. 10. 26. 16:19
반응형

 

용어 정리

relation == table

tuple == row == record

attribute == column

degree: attribute의 수 5

cardinality: 튜플의 수 4

degree는 1이상이어야한다

cardinality는 0 일 수 있다

null value

null은 0이 아니다

null != empty space or blank

characteristic of relatoin

같은 이름을 가진 relaiton은 존재할 수 없다

attribute도 마찬가지

 

 

 

key is an attribute

types of keys

super key

candidate key

primary key

alternate key

foreign key

super key: unique value를 포함한 set

candidate key: super key중에 가장 작은 set

primary key: candidate 중에 하나를 선택한 것

alternate key: candidate key 중 primary key가 아닌 것

 

 

이렇게 보면 이해가 안되니까 그림으로 보면

 

 

이런 형태이다

 

 

 

 

 

 

Foreign key

데이터베이스 사이의 연관관계 표시한 키

 

 

 

 

 

 

types of foreign key

1. 다른 테이블

2. 자기자신

3. composite(두개이상 열)

 

Integrity Constraints: 무결성 제약조건

Entity integrity constraint(primary key와 관련)

  1. 모든 테이블은 primary key가 있다
  2. primary key로 선택된 attribute는 unique한 값이여야 한다
  3. primary key는 null값을 가질 수 없다

 

 

 

 

Domain integrity constraint(attribute랑 관련)

domain==data type

1.attribute를 사용하려면 data type을 선언해야한다

2.각 튜플에는 하나의 attribute에 하나의 값만 가질 수 있다

3.한 attribute의 모든 값은 같은 data type이어야한다

Referential integrity constraint(foreign key와 관련)

  1. 다른 테이블 참조하는 foreign key는 다른 테이블에 쓸 수 있는 값이어야 한다

 

​ quiz

  1. indicate the followings: relaiton name, tuples, attributes, cardinality and degree
  2. For the same relation, show the followings: super keys, candidate keys, primary key and alternate key

 

 

 

 

 

 

 

 

 

 

 

 

 

1. ANSWER

relation name : The student

tuples: (1000, Tim, Computer, Male, tim@gmail.com)

(1001, Sonya, Art, Female, sonya@naver.com)

(1002, Brain, Social, Male, brain@yahoo.com)

(1003, Natasha, Math, Female, natsha@outlook.com)

attribute: ID, Name, Major, Grade, Email

cardinality: 4

degree: 5

 

 

 

 

 

 

 

 

 

 

 

 

2.ANSWER

super keys:

{ID}, 

{ID, Name}, {ID, Major}, {ID, Grade}, {ID, Email},

{ID, Name, Major}, {ID, Name, Grade}, {ID, Name, Email},

{ID, Major, Grade}, {ID, Major, Email}, {ID, Grade, Email},

{ID, Name, Major, Grade}, {ID, Name, Major, Email}, {ID, Major, Grade, Email},

{ID, Name, Major, Grade, Email},

{Email},

{Email, Grade}, {Email, Major}, {Email, Name},

{Email, Grade, Major}, {Email, Grade, Name}, {Email, Major, Name},

{Email, Grade, Major, Name}

 

 

candidate keys:

{ID}, {Email}

 

primary key: ID

 

alternate key: Email

 

 

반응형

'개념 > 데이터베이스시스템' 카테고리의 다른 글

Indexing  (0) 2022.11.11
Advanced Queries  (0) 2022.10.26
Intermediate SQL QUIZ  (0) 2022.10.26
Basic SQL  (0) 2022.10.26
Introduction to database  (0) 2022.10.26
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함