(user, quiz, option)을 response의 필드로 두고 (user, quiz)에 unique constraint를 걸면, option이 quiz 소속인지를 보장 할 수 없는데, 이거까지 보장하는건 쉽지 않습니다.

@theeluwin제이미 option 테이블의 기본 키를 (quiz_id, index) 정도의 복합 키로 만든 뒤에, response 테이블의 (quiz_id, option_index)option 키의 외래 키로 만들면 option이 어느 quiz의 소속인지 강제할 수 있지 않을까요?

1

If you have a fediverse account, you can quote this note from your own instance. Search https://hackers.pub/ap/notes/0197af50-0070-79b2-9560-02956736fb31 on your instance and quote it. (Note that quoting is not supported in Mastodon.)