SQL Tutorial · Advanced SQL · Lesson 36 of 36

SQL Next Steps

Where to go next: database design, performance and interview practice.

You can query and change data — what's next?

  • Database design: normalisation (1NF–3NF), choosing keys, modelling many-to-many relationships with junction tables (like order_items).
  • Performance: reading query plans, indexing strategies, avoiding N+1 queries from your application.
  • A real server: install PostgreSQL locally (or with Docker) and connect from your favourite language — see the database lessons in the Python, PHP and Java tutorials.

Practise for interviews

Challenge yourself

Try writing these against the sample database:

  1. The best-selling product by quantity.
  2. Each customer's first order date.
  3. Revenue per category, including categories with no sales.
One possible answer to challenge 1Try it yourself
-- 1. Best-selling product by quantity
SELECT p.name, SUM(oi.quantity) AS units
FROM order_items oi JOIN products p ON p.product_id = oi.product_id
GROUP BY p.product_id ORDER BY units DESC LIMIT 1;

Output

name | units
Rubber Duck | 13