Model data with SQL
Start with a fictional student events service. Separate events, venues and registrations instead of keeping every fact in one spreadsheet.
Break it down
01Build it yourself
Draw the relationships and create tables with primary keys, foreign keys and meaningful constraints. Insert a small sample dataset, join registrations to events and count registrations per event. Include an event with no registrations.
02Ready to move on?
Explain the grain of each table and why a join might duplicate rows. Your query includes zero-registration events and rejects a registration for a nonexistent event.
Take it further
Continue learning on these source websites.
PostgreSQL: relational databases and SQL tutorial(opens in a new tab)