Anomaly, Normalization
✅ Anomaly
이상 현상
테이블을 잘못 설계하여 데이터 삽입, 삭제, 수정할 때 오류 발생
>
1. Insertion Anomaly
need to add unnecessary data to instert
- when is primary key,
- if need to save students who did not take a course
- these students’ course ID would be null
- primary key cannot be null
- thus, cannot insert students who did not take a course, unless adding unnecessary data
2. Update Anomaly
updating a part of data, so that data is not consistent
- update student deparement from music to computer
- need to update all deparetments
- update anomality happends when update miss to update ome departments
3. Deletion Anomaly
deleting even the necessary data
- when student withdraw from a course
- delete student information as well
✅ Normalization
정규화
중복을 최대한 줄여 데이터 구조화
불필요한 데이터 제거, 논리적으로 데이터 저장
goal: data integrity
reduce data repetition, increase data integrity
- 👍🏻 data integrity
- 👍🏻 save DB resource
✔️ 1NF(First Normal Form)
table column to have one atomic value
Don’t use multiple fields in a single table to store similar data
- one phone number per user
- one feature per user
✔️ 2NF
Create separate tables for sets of values that apply to multiple records.
Relate these tables with a foreign key
- 제 1 정규화를 진행한 테이블에 대해 완전 함수 종속 만족시키기
완전 함수 종속: 기본키의 부분집합이 결정자가 되어선 안된다.
- user address is used in customer table, orders, shipping, invoices table.
- do not repeat this field as a seperate entry in all tables, but place it on customer table and set foreign key
✔️ 3NF
Elimiate fields that don’t depend on key
- 제 2 정규화를 진행한 테이블에 대해 이행적 종속 없애기
- 이행적 종속:
A -> B
,B -> C
가 성립할 때,A -> C
가 성립하는 것
✔️ BCNF 정규화
- 제 3 정규화를 진행한 테이블에 대해 모든 결정자가 후보키가 되도록 테이블 분해
This post is licensed under CC BY 4.0 by the author.