데이터를 중복 저장하지않기 위해 분리
정규화가 된 결과를 정규형
=>정규화는 단계적으로 진행되야한다는 점에 유의
처음 생성된 테이블
엑셀 하나의 칸에는 하나의 값만 들어가도록 분리
Primary Key(기본키) 와 Composite Key(복합키)
Primary Key : 한 줄의 데이터를 구분할 수 있는 유일한 키
Composite Key : 데이터를 대표하는 키가 여러 개의 컬럼으로 구성된 것
A → B → C의 관계를 가지고 있을때, A와 B, B와 C를 묶어 다른 테이블로 분리하는 것
=> 중복된 값이 없을 때까지 ID를 부여하며 계속 테이블을 분리함
테이블 간의 관계를 보여주는 그림 i.e) ERDCloud
📌PK & FK
PK (primary key)
는 기본키로 그 테이블에서 데이터들을 구분할 수 있는 유니크한 값 i.e)id
FK (foreign key)
는 외래키(참조키)로 다른 테이블에서 값을 참조할 때 참조해오는 테이블의 PK(기본키)
즉, 다른 테이블의id
값
three main cardinalities
A one-to-one relationship (1:1). For example, if each customer in a database is associated with one mailing address.
A one-to-many relationship (1:M). For example, a single customer might place an order for multiple products. The customer is associated with multiple entities, but all those entities have a single connection back to the same customer.
A many-to-many relationship (M:N). For example, at a company where all call center agents work with multiple customers, each agent is associated with multiple customers, and multiple customers might also be associated with multiple agents.▶︎중간테이블 생성
데이터베이스의 구조(개체, 속성, 관계)와 제약 조건에 대한 정의
3층 구조
- 외부 스키마(External Schema) : 프로그래머나 사용자의 입장에서 데이터베이스의 모습으로 조직의 일부분을 정의한 것
- 개념 스키마(Conceptual Schema) : 모든 응용 시스템과 사용자들이 필요로하는 데이터를 통합한 조직 전체의 데이터베이스 구조를 논리적으로 정의한 것
- 내부 스키마(Internal Schema = Storage Schema) : 전체 데이터베이스의 물리적 저장 형태를 기술하는 것
five basic components of an entity relationship diagram
- Entities, which are objects or concepts that can have data stored about them. Entities refer to tables used in databases.
- Attributes, which are properties or characteristics of entities. An ERD attribute can be denoted as a primary key, which identifies a unique attribute, or a foreign key, which can be assigned to multiple attributes.
-The relationships between and among those entities.- Actions, which describe how entities share information in the database.
- Connecting lines