Foreign Key
외래 키
외래 키는 데이터베이스 규칙입니다. 하나의 열이 동일하거나 다른 테이블의 유효한 키를 가리키도록 합니다. `null`은 해당 열에 선택된 규칙을 따릅니다.
다른 예시
모든 `invoice_line.invoice_id`는 기존 송장을 가리켜야 합니다. 초안을 삭제하면 그 항목들도 삭제되지만, 게시된 송장은 삭제할 수 없으며 반전 과정이 필요합니다. 대량 가져오기는 잘못된 행을 따로 보관하며 외래 키를 영구적으로 끄는 대신 처리합니다.
주요 부분
- 01참조 열
- 02참조된 후보 키
- 03업데이트/삭제 작업
사용할 때
데이터베이스 관계가 누락된 부모를 가리키지 않아야 할 때는 외래 키를 사용하십시오. 업데이트와 삭제 작업을 신중하게 선택하십시오.
다음 경우에는 사용하지 마세요
동시성에서는 앱 검증만 의존하지 마십시오. 캐스케이드 삭제가 경계를 넘기 전에 데이터 보존 및 감사 의무를 검토하십시오.
코드에서 사용된 이름
FOREIGN KEY (…) REFERENCES … ON UPDATE/DELETE … 출시하기 전에
Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback.
Outcome:Complete the task with 외래 키 (Foreign Key)。 User context:모든 `invoice_line.invoice_id`는 기존 송장을 가리켜야 합니다. 초안을 삭제하면 그 항목들도 삭제되지만, 게시된 송장은 삭제할 수 없으며 반전 과정이 필요합니다. 대량 가져오기는 잘못된 행을 따로 보관하며 외래 키를 영구적으로 끄는 대신 처리합니다. Technical concept or control:외래 키 (Foreign Key)。 Why it fits:데이터베이스 관계가 누락된 부모를 가리키지 않아야 할 때는 외래 키를 사용하십시오. 업데이트와 삭제 작업을 신중하게 선택하십시오. Do not use it when:동시성에서는 앱 검증만 의존하지 마십시오. 캐스케이드 삭제가 경계를 넘기 전에 데이터 보존 및 감사 의무를 검토하십시오. Engineering requirements: Define inputs, outputs, contracts, and rules that must always hold. Set authorization and input checks. Define failures, timeouts, retries, one-time effects, data moves, and compatibility limits. Operations: Add useful signals and logs that hide sensitive data. Set capacity limits and write an operator guide. Test recovery and rollback. Acceptance criteria: Contract and failure-path tests pass. Data and authorization rules still hold during retries and partial failures. Check performance limits, monitoring, recovery, and rollback. Evidence and limits (evidence boundary):해당 출처에 대해 공식적인 것입니다. 다른 플랫폼이나 팀은 그 용어를 다른 방식으로 사용할 수 있습니다. Unknowns to confirm: Where the code runs, data stores, traffic shape, consistency needs, and the security boundary. Also confirm the compatibility period, service goals, and rollback limits.
이 요청을 확인하세요
Review how 외래 키 (Foreign Key) is used now. Definition: 외래 키는 데이터베이스 규칙입니다. 하나의 열이 동일하거나 다른 테이블의 유효한 키를 가리키도록 합니다. `null`은 해당 열에 선택된 규칙을 따릅니다. Release checks: Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.