概要 データベーステーブルの物理設計を行うとき、論理削除とユニークキー制約を両立させるための TIPS です。 基本形 create table user ( id int not null, email varchar(40) not null, password_sha256 varchar(64) not null, removed int not null default 0, -- 論理削除カラム constraint pk primary key (id) ); -- 入会 insert into user (id, email, password_sha256) values (1, 'foo@example.com', '**dummy**'); -- ログイン removed = 0 select * from user where removed = 0 and ema