관리 메뉴

너와 나의 스토리

Week2 DB - Relational Model 본문

Data Analysis/Database

Week2 DB - Relational Model

노는게제일좋아! 2019. 3. 13. 21:13
반응형

Hierarchical Model vs Relation Model

- Hierarchical Model

ex)

 employee

             ____|____

             |                |

  job history   children         


 employee ( id, name, birth_date, jobhistory, children)

 jobhistory ( data, title, salary )


*어떤 직원의 job history를 찾으려면 employee 목록에서 찾은 다음 jobhistory에 가서 또 찾아야 한다.


- Relation Model

ex)

relation 1 ->  employee ( id, name, birth_date )

relation 2 ->  jobhistory ( id, title, salary ) 


* 모두 테이블로 만들고 각각 key가 존재하게 함



 Attribute Types

- domain : attribute set

- atomic : attribute value는 하나의 값이여야한다.

- null : 값이 없을 때 (null은 모든 domain의 멤버이다)



 Keys

: relation 안의 column(=attribute)들은 구분되는 key값을 가진다

- Superkey : 유일한 key값들 중 하나 이상 선택

ex) { ID }, { ID, name } 둘 다 superkey

- Candidate Key : minimal

ex) { ID }                        // 하나의 요소만으로도 유일한 값을 가진다면 원소의 개수는 1개 (.....맞낭...?)

* Superkey ⊇ Candidate Key


- Primary key : 사용자가 선택한 key

- Foreign key : 어떤 relation에 있는 value는 다른 곳에서도 존재한다 

Referencing relation

Referenced relation




* 뒷부분 추가할 예정

반응형

'Data Analysis > Database' 카테고리의 다른 글

DB - hashing  (0) 2019.06.01
DB - indexing  (0) 2019.06.01
DB - mySQL 공부  (0) 2019.04.11
DB실습 - JDBC를 이용한 mySQL  (0) 2019.04.06
week1 DB - Introduction  (0) 2019.03.13
Comments