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
- SQL & databases interview questions
- Databases & transactions questions
- Orders CSV report — the same aggregation thinking, in code.
Challenge yourself
Try writing these against the sample database:
- The best-selling product by quantity.
- Each customer's first order date.
- Revenue per category, including categories with no sales.
-- 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