๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ป Computer Science/๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค25

[๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค] DBMS(Database Management System) ๋ž€? DBMS(Database Management System) ๋ž€?๋ฐ์ดํ„ฐ๋ฅผ ์ฒด๊ณ„์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ , ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ์‚ฌ์šฉ์ž ๊ฐ„์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ์†Œํ”„ํŠธ์›จ์–ด์ž…๋‹ˆ๋‹ค.DBMS๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ, ์ˆ˜์ •, ๊ฒ€์ƒ‰, ์‚ญ์ œ ๋“ฑ ๋‹ค์–‘ํ•œ ์ž‘์—…์„ ํšจ์œจ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋ฉฐ, ๋ฐ์ดํ„ฐ์˜ ๋ฌด๊ฒฐ์„ฑ, ๋ณด์•ˆ, ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๋Š”๋ฐ ์ค‘์š”ํ•œ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.๋ˆ„๊ตฐ๊ฐ€ " ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ DBMS๋ฅผ ๋งํ•ด์ฃผ์„ธ์š”." ๋ผ๊ณ  ๋ฌผ์–ด๋ณธ๋‹ค๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์€ ๋‹ค์–‘ํ•œ DBMS ์˜ˆ์‹œ๋ฅผ ์ œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. DBMS ์ข…๋ฅ˜์ข…๋ฅ˜์ •์˜์˜ˆ์‹œRDBMS (๊ด€๊ณ„ํ˜• DBMS)๋ฐ์ดํ„ฐ๋ฅผ ํ…Œ์ด๋ธ”๋กœ ๊ตฌ์กฐํ™”ํ•˜๋ฉฐ, SQL์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.Oracle, MySQL, PostgreSQL, SQL ServerNoSQL DBMS๋น„์ •ํ˜• ๋ฐ์ดํ„ฐ๋‚˜ ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์„ค๊ณ„๋œ DBMS.. 2024. 9. 19.
[๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค] JOIN ์ข…๋ฅ˜(FULL OUTER, SELF, NATURAL, CROSS) ์˜ˆ์ œ ํฌํ•จ FULL OUTER, SELF, NATURAL, CROSS ์š”์•ฝFULL OUTER JOIN๋‘ ํ…Œ์ด๋ธ”์˜ ๋ชจ๋“  ํ–‰์„ ๊ฒฐํ•ฉํ•˜๋ฉฐ, ์ผ์น˜ํ•˜์ง€ ์•Š๋Š” ํ–‰์€ NULL๋กœ ์ฑ„์›Œ์ง‘๋‹ˆ๋‹ค.SELF JOINํ…Œ์ด๋ธ”์„ ์ž๊ธฐ ์ž์‹ ๊ณผ ์กฐ์ธํ•˜์—ฌ ๊ฐ™์€ ํ…Œ์ด๋ธ” ๋‚ด์—์„œ ํ–‰ ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค.NATURAL JOIN๋‘ ํ…Œ์ด๋ธ” ๊ฐ„์˜ ๋™์ผํ•œ ์ด๋ฆ„์„ ๊ฐ€์ง„ ๋ชจ๋“  ์—ด์„ ๊ธฐ์ค€์œผ๋กœ ์ž๋™์œผ๋กœ ์กฐ์ธํ•ฉ๋‹ˆ๋‹ค.CROSS JOIN๋‘ ํ…Œ์ด๋ธ” ๊ฐ„์˜ ๋ชจ๋“  ๊ฐ€๋Šฅํ•œ ์กฐํ•ฉ์„ ์ƒ์„ฑํ•˜์—ฌ ์นดํ‹ฐ์…˜ ๊ณฑ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. 1. FULL OUTER JOINFULL OUTER JOIN์€ ๋‘ ํ…Œ์ด๋ธ” ๊ฐ„์˜ ๋ชจ๋“  ํ–‰์„ ๊ฒฐํ•ฉํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ์–‘์ชฝ ํ…Œ์ด๋ธ”์—์„œ ์ผ์น˜ํ•˜๋Š” ํ–‰์€ ํ•˜๋‚˜๋กœ ๊ฒฐํ•ฉ๋˜๋ฉฐ, ์ผ์น˜ํ•˜์ง€ ์•Š๋Š” ํ–‰๋„ ํฌํ•จํ•˜์—ฌ NULL ๊ฐ’์œผ๋กœ ์ฑ„์›Œ์ค๋‹ˆ๋‹ค ์˜ˆ์‹œํ…Œ์ด๋ธ” Customers: CustomerID Custo.. 2024. 8. 23.
[๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค] ๊ณ„์ธตํ˜• ์ฟผ๋ฆฌ์˜ ORDER SIBLINGS BY ๋ž€? ์˜ˆ์ œ ํฌํ•จ ORDER SIBLINGS BY ๋ž€?ORDER SIBLINGS BY๋Š” Oracle SQL์—์„œ ๊ณ„์ธตํ˜• ์ฟผ๋ฆฌ(Hierarchical Query)๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ, ๊ฐ™์€ ๋ถ€๋ชจ๋ฅผ ๊ฐ€์ง„ ํ˜•์ œ ๋…ธ๋“œ๋“ค(Sibilings)์„ ํŠน์ • ๊ธฐ์ค€์— ๋”ฐ๋ผ ์ •๋ ฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.์ด๋Š” CONNECT BY ์ ˆ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ๋˜๋ฉฐ, ๊ณ„์ธต ๊ตฌ์กฐ ๋‚ด์—์„œ ๊ฐ™์€ ๋ ˆ๋ฒจ(๊ฐ™์€ ๋ถ€๋ชจ๋ฅผ ๊ณต์œ ํ•˜๋Š”) ํ˜•์ œ๋“ค๋งŒ ์ •๋ ฌํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ณ„์ธตํ˜• ์ฟผ๋ฆฌ์˜ ๊ธฐ๋ณธ ๊ฐœ๋…Oracle์˜ ๊ณ„์ธตํ˜• ์ฟผ๋ฆฌ๋Š” ํŠธ๋ฆฌ ๊ตฌ์กฐ์™€ ๊ฐ™์€ ๊ณ„์ธต์  ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.CONNECT BY ์ ˆ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ถ€๋ชจ-์ž์‹ ๊ด€๊ณ„๋ฅผ ์ •์˜ํ•˜๊ณ , START WITH ์ ˆ์„ ์‚ฌ์šฉํ•˜์—ฌ ํŠธ๋ฆฌ์˜ ๋ฃจํŠธ ๋…ธ๋“œ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.START WITH : ํŠธ๋ฆฌ ๊ตฌ์กฐ์—์„œ ์‹œ์ž‘ํ•  ๋ฃจํŠธ ๋…ธ๋“œ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.CONNECT BY PR.. 2024. 8. 23.
[๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค] ๊ทธ๋ฃนํ•จ์ˆ˜ (ROLLUP, CUBE, GROUPING SETS)๋ž€? ์˜ˆ์ œ ํฌํ•จ ROLLUP, CUBE, GROUPING SETS๋Š” SQL์—์„œ ์ง‘๊ณ„ ๊ฒฐ๊ณผ๋ฅผ ๊ทธ๋ฃนํ™”ํ•˜๋Š” ๋‹ค์–‘ํ•œ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.์ด๋“ค์€ ๋ฐ์ดํ„ฐ์˜ ์—ฌ๋Ÿฌ ์ง‘๊ณ„ ์ˆ˜์ค€์„ ๊ณ„์‚ฐํ•˜๊ฑฐ๋‚˜ ๋ณด๊ณ ์„œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ROLLUP, CUBE, GROUPING SETS ์š”์•ฝ ์ •๋ฆฌ ROLLUP ์ง€์ •๋œ ์—ด ์ˆœ์„œ์— ๋”ฐ๋ผ ๊ณ„์ธต์  ์ง‘๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์†Œ๊ณ„์™€ ์ด๊ณ„๋ฅผ ํฌํ•จ CUBE ์ง€์ •๋œ ์—ด์˜ ๋ชจ๋“  ๊ฐ€๋Šฅํ•œ ์กฐํ•ฉ์— ๋Œ€ํ•ด ์ง‘๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์ฐจ์› ๋ถ„์„์— ์œ ์šฉ GROUPING SETS ์‚ฌ์šฉ์ž๊ฐ€ ์ •์˜ํ•œ ํŠน์ • ๊ทธ๋ฃนํ™” ์ง‘ํ•ฉ์— ๋Œ€ํ•ด ์ง‘๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์žฅ ์œ ์—ฐํ•˜๊ฒŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ ํ•œ ์ค„ ์š”์•ฝ์œผ๋กœ ์™ธ์šฐ๊ธฐROLLUP = "์ญ‰ ๋ง์•„๊ฐ€๋Š” ์†Œ๊ณ„์™€ ์ด๊ณ„"๊ทธ๋ฃนํ•‘ ์—ด์ด ์ˆœ์ฐจ์ ์œผ๋กœ ์†Œ๊ณ„๋ฅผ ํฌํ•จํ•˜๋ฉด์„œ ์ ์  ๋” ํฐ ์ง‘๊ณ„๋ฅผ ๋งŒ๋“ ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.CUBE = "๋ชจ๋“  ๋ฐฉํ–ฅ์—์„œ ์™„์ „ํ•œ ์ง‘๊ณ„".. 2024. 8. 22.
728x90
๋ฐ˜์‘ํ˜•