50장. Schema Review에서 미래 장애를 찾는다
money는 floating point가 아니라 정밀도와 통화 계약을 가진 decimal 또는 정수 단위로 설계한다. TIMESTAMP와 DATETIME, session timezone, DST와 표시 timezone을 구분한다. 문자열 collation은 비교·정렬·unique와 index 길이에 영향을 주므로 서비스 locale과 실제 검색을 시험한다. 모든 table에 의미 있는 primary key를 두고 secondary index가 PK를 포함하는 비용을 계산한다.
soft delete는 모든 unique·FK·query에 조건을 퍼뜨리며 보존 정책을 대신하지 않는다. history가 필요하면 current row 덮어쓰기보다 append event 또는 version table을 검토한다. 큰 JSON column은 schema 진화를 쉽게 보이게 하지만 검색·constraint·부분 update·replication 비용을 설명해야 한다. generated column index도 원본 표현과 type을 계약으로 둔다.
review 결과는 ERD 한 장이 아니라 예상 cardinality, 성장률, 핵심 query, constraint, delete/retention, migration과 rollback을 포함한다. seed는 평균 주문뿐 아니라 큰 seller, 긴 문자열, 같은 시각과 중복 key를 넣는다. production DDL 전에 old/new application contract와 backup restore를 같은 후보 schema로 실행한다.