codestates / codestates/Bobpago

[🚨Err Handling] Mysql db 직접 μ‚­μ œν• λ•Œ λ°œν–‰ ν•˜λŠ” μ—λŸ¬

Open
#86 0 comments 0 reactions 1 assignee Claimed by @tjdgns5272 View on GitHub
error handling
Dominant language
TypeScript
Stars
5
Forks
3
PR merge metrics
No merged PRs in 30d

Description

### μ–΄λ–€ μ—λŸ¬μΈκ°€μš”?
- Mysql db ν…Œμ΄λΈ”μ—μ„œ 데이터 row 직접 μ‚­μ œν• λ•Œ λ°œν–‰ ν•˜λŠ” μ—λŸ¬

### μ—λŸ¬ λ©”μ‹œμ§€
[
![image](https://user-images.githubusercontent.com/69573484/134809509-3e9f68f3-8144-4f62-8a33-09a2e1243409.png)
](url)
```bash
$ ERROR 1451: 1451: Cannot delete or update a parent row: a foreign key constraint fails
```

### μ—λŸ¬ 핸듀링 방법

- 핸듀링 방법에 λŒ€ν•΄μ„œ κ°„λ‹¨ν•˜κ²Œ κΈ°λ‘ν•΄λ³΄μ„Έμš”.
foreign key κ°€ κ±Έλ¦° ν…Œμ΄λΈ”μ„ 쿼리둜 직접 μ‚­μ œν•  λ•ŒλŠ” μ˜ˆμ™Έκ°€ κ±Έλ¦°λ‹€.
ν…Œμ΄λΈ” μ‚­μ œ μ‹œ, foreign key둜 관계가 μ„€μ •λœ ν…Œμ΄λΈ”μ΄ μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” ν…Œμ΄λΈ”μ„ μ°Έμ‘°ν•˜κ²Œ λ˜λŠ” (λΆˆμ•ˆμ •ν•œ) 이상 μƒνƒœκ°€ λ˜μ–΄ DBMSμ—μ„œ 사전에 λ°©μ§€λ₯Ό ν•΄μ£ΌλŠ” 것인데, 이λ₯Ό λ¬΄μ‹œν•˜κ³  κ°•μ œλ‘œ μ‚­μ œλ₯Ό ν•˜λ €λ©΄ λ‹€μŒ μ•„λž˜λ₯Ό μ‹€ν–‰ν•˜λ©΄λœλ‹€.

1. foreign key 체크 섀정을 λΉ„ν™œμ„±ν™”ν•˜κ³ 
2. ν…Œμ΄λΈ”μ„ μ‚­μ œμ‹œν‚¨λ‹€.
3. ν…Œμ΄λΈ” μ‚­μ œ ν›„ λ‹€μ‹œ foreign key 체크λ₯Ό ν™œμ„±ν™”ν•˜μ—¬ μ•ˆμ „μ„±μ„ μ§€μΌœμ£Όλ©΄ λœλ‹€.

[
![image](https://user-images.githubusercontent.com/69573484/134810307-768fae3a-8f9f-4a5f-9fac-12c1f506968c.png)
](url)

### μ—λŸ¬ 핸듀링을 μœ„ν•΄ μ°Έκ³ ν•œ 레퍼런슀 링크

[링크](https://reeme.tistory.com/39)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.