[DB] Design Principles

Manx·2022년 4월 29일
0

SQL 레벨업

목록 보기
4/11

Design Principles

좋은 설계를 위해서 지켜야 하는 것이 무엇이 있을까?

  • Faithfulness
  • Avoiding redundancy
  • Simplicity counts
  • Choosing the right relationships
  • Picking the right kind of element

Faithfulness

  • 디자인은 구체화하기 위해 fauthful(충실) 해야 한다.
  • Attributes와 relationships sets는 현실적으로 연관이 있어야 한다.

ex)
Stars(number-of-cylinders) : Star와 엔진과 연관이 있는가? X
Automobiles(number-of-cylinders) : 자동차와 엔진은 실제로 연관이 있다.

Avoiding Redundancy

  • 모든 것을 한 번만 선언하게 끔 하여야 한다.

Movies의 StudioName과 Studios의 name이 중복 선언되었다.
중복으로 선언할 시 용량을 낭비할 수 있고, 수정할 시 오류(한쪽만 수정하는 경우)가 발생할 수 있다.

Simplicity Counts

  • 중요하지 않은 테이블을 생성해 디자인이 복잡해지는 것을 방지해야 한다.
    Holdings : 불필요한 릴레이션, 복잡하다.

Choosing the Right Relationship Sets

Entity sets는 다양한 루트로 relationship set과 연결될 수 있다.
그러나 가능한 모든 relationship set에 추가하는 것은 좋지 않다.

  • 중복이 발생할 수 있다.
  • 용량이 낭비될 수 있다.
  • 알아보기 힘들다.

Star가 Movie에 출연하는 Star라면 Studio에서 Star의 중복이 발생한다.
그런데 만약, Movie에 출연하지 않는 Star라면 중복은 발생하지 않는다.
-> 연관관계가 원을 이루면 중복일 가능성이 높다.

Weak Entity Sets

Weak entity set : primary key를 가지고 있지 않은 개체의 집합 ↔ strong entity set
weak entity set의 key는 다른 entity set의 속성의 집합에 의존한다. → identifying entity set(식별 개체 집합)
identifying entity set과 weak entity set은 One to Many 관계이다.
weak entity set은 primary key를 가지고 있지 않지만, 그나마 식별할 수 있는 키를 Discriminator라고 한다.


Crews's Primary Key : (number, StudiosName)


Reference

profile
백엔드 개발자

0개의 댓글