๋ชฉ๋ก์ฐธ์กฐ๋ฌด๊ฒฐ์„ฑ (1)

YS's develop story

์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ ๋ฐ Cascade

์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ (Referential Integrity)์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€? ์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ์€ ๊ด€๊ณ„ํ˜• ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ชจ๋ธ์—์„œ 2๊ฐœ์˜ ๊ด€๋ จ ์žˆ๋Š” ๊ด€๊ณ„ ๋ณ€์ˆ˜ ๊ฐ„์˜ ์ผ๊ด€์„ฑ์„ ๋งํ•ฉ๋‹ˆ๋‹ค '์ฃผ์–ด์ง„ ์†์„ฑ ์ง‘ํ•ฉ์— ๋Œ€ํ•ด ํ•œ ๊ด€๊ณ„์— ๋‚˜ํƒ€๋‚˜๋Š” ๊ฐ’์ด ๋‹ค๋ฅธ ๊ด€๊ณ„์—์„œ ํŠน์ • ์†์„ฑ ์ง‘ํ•ฉ์— ๋Œ€ํ•ด์„œ๋„ ๋‚˜ํƒ€๋‚˜๋„๋ก ๋ณด์žฅํ•ด์•ผ ํ•œ๋‹ค'๋ผ๊ณ  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ต์žฌ์— ๋‚˜์™€ ์žˆ๋„ค์š”. ์ฆ‰ ์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ์ด๋ž€ ๊ธฐ๋ณธํ‚ค์™€ ์ฐธ์กฐ ํ‚ค ๊ฐ„์˜ ๊ด€๊ณ„๊ฐ€ ํ•ญ์ƒ ์œ ์ง€๋˜๋„๋ก ๋ณด์žฅํ•˜๋Š” ๊ฒƒ์„ ๋งํ•ฉ๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค๋ช…ํ•˜์ž๋ฉด ๊ต์› ํ…Œ์ด๋ธ”์˜ departmentName์ด Foreign key์ด๊ณ  ๊ทธ ๊ฐ’์ด 'Biology'์ด๋ฉด ์‹ค์ œ๋กœ ํ•™๊ณผ ํ…Œ์ด๋ธ”์— 'Biology'๊ฐ€ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋‘ ๊ฐ’์€ ํ•ญ์ƒ ๊ฐ™์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ด€๊ณ„๊ฐ€ ์œ ์ง€๋˜๋„๋ก ํ•˜๋Š” ๊ฒƒ์„ ์ฐธ์กฐ ๋ฌด๊ฒฐ์„ฑ์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์œ„์™€ ๊ฐ™์€ ํŠœํ”Œ์„ ์ถ”๊ฐ€ํ•˜..

Database 2021. 5. 18. 08:56