Practicing using Django as server framework and gaining experience with relational database design.
๊ด๊ณํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋์์ธ๊ณผ Django ์๋ฒ ํ๋ ์์ํฌ๋ฅผ ์ฐ์ตํด๋ณด๊ธฐ ์ํ ์น ์๋ฒ ๊ฐ๋ฐ.
- For CS50 Web Programming with Python and JavaScript - project 3.
- Created an online ordering service for a pizza restaurant.
- Used Django as the server framerwork.
- ํ๋ฒ๋์ CS50 MOOC(edX)์ Web Programming with Python and JavaScript ์์ ์ ํ๋ก์ ํธ 3.
- ์จ๋ผ์ธ์ผ๋ก ํผ์๋ฅผ ์ฃผ๋ฌธํ ์ ์๋ ์น ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ.
- Django๋ฅผ ์๋ฒ ํ๋ ์์ํฌ๋ก ์ฌ์ฉํจ.
This
Importance of Understanding ORM (Object Relational Mapping) with Databases
- ํด๋์ค ์ ์์ ๊ฐ์ฒด ๊ตฌ๋ถํ๊ธฐ
- ex. order class: ๊ฐ์ฒด order1, order2 ๋ง๋ค ์ ์์
- class ์ ์์ foreignkey field๊ฐ ์์ผ๋ฉด ์ด๊ฑฐ๋ ๊ทธ class์ __object__์ ์ฐ๊ฒฐ์ด ๋๋ ๊ฒ์ด๋ค! (not the actual class)
- ๋ชจ๋ธ/table ์ฐ๊ฒฐ์ํค๊ธฐ
- inbetween table ์๊ฐํ๋ฉฐ ์ด๋ป๊ฒ ์ฐ๊ฒฐ์ํฌ์ง ์๊ฐํ๊ธฐ
- multiple instance of one model์ ํ model์ object์ link.
- ๋ฐฉ๋ฒ: ๅค๊ฐ์ธ ๋ชจ๋ธ ์์ foreign key ์ ์ํ์ฌ ๋ค๋ฅธ ๋ชจ๋ธ๊ณผ ์ฐ๊ฒฐ (๊ทธ๋ผ ํ๋์ธ ๋ชจ๋ธ์ด related_name์ผ๋ก ์ ์๋๋ reverse accessor๋ก ๋ค๋ฅธ ๊ฒ์ ๋ชจ๋ ์ ๊ทผํ ์๊ฐ ์๋ค!)
- ๊ทธ๋ฆผ์ผ๋ก ๋ํ๋ด๊ธฐ!! ํ๋๊ฐ ์ฌ๋ฌ๊ฐ์ ์ฐ๊ฒฐ๋๋ ๋ชจ์ต
- ex. 1 post with multiple images
- ex. 1 order with multiple pizzas
- cf) choice option in fields for models vs. creating separate model and accessing by foreign key
- ๋ ๋ค foreign key๋ก ์ ๊ทผํ๋
- ex. flight์ origin์ผ๋ก airport ๊ฐ์ฒด ์ง์ ๊ฐ๋ฅ (flight 1 = ํ์ฝฉ์์ ์ถ๋ฐ)
- code๋ก ์ง์ ์์ ํด์ผ ํจ vs. admin์์ ์์ ๊ฐ๋ฅ (GUI)
- ๊ฒฐ๊ตญ, separate model ๋ฐฉ์์ด ๋ ๋์.