Concept
SQL selects, filters, joins and aggregates rows. From Node you send parameterised queries, so values are never spliced into the query text. Reading the query plan tells you whether it is fast.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show SQL queries doing its job.
import postgres from "postgres";
const sql = postgres(process.env.DATABASE_URL);
const recent = await sql`
SELECT o.id, o.total_cents, c.email
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE o.created_at > now() - interval '7 days'
AND c.email = ${email}
ORDER BY o.created_at DESC
LIMIT 20`;Building a query with string concatenation and a user value. It is SQL injection: a crafted value changes the query. Always pass values as parameters.
Once a session shows you understand SQL queries, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on SQL queries.