The Relational Model
What this is. A relational database stores data in tables. A table holds one kind of thing, a row is one of them, and a column is one fact about it.
That sounds like a spreadsheet and the difference matters. In a spreadsheet a cell can hold anything, rows have positions, and the same fact gets typed in twenty places. In a database a column has one type and one meaning, rows have no inherent order, and each fact is stored once and referred to.
Why learn this when Django writes the queries. Because the ORM is an abstraction over SQL, and every abstraction leaks.
The Django course taught you select_related, prefetch_related, N+1 queries and sqlmigrate. Every one of those is about SQL. You were optimising queries you could not read. This course is where you learn to read them, and it is also the most transferable thing in the whole curriculum: SQL has outlived every ORM built on top of it.
✦ Rows have no order
Without ORDER BY, the database may hand rows back in any order it finds convenient, and it is allowed to change its mind between runs. If order matters to your answer, you must say so. This is the first habit worth building.
Mark this lesson complete
Your progress is saved on this device. No account needed.