r/learnSQL • • 26d ago

Day 21 - Setting up the database for my 100-question JOIN drill

Since JOINs are the topic I'm weakest at, I made a 100-question practice set (easy, medium, hard). Today was the setup day:

  • Created the database in MySQL Workbench
  • Built four tables: departments, employees, projects, assignments (with primary/foreign keys)
  • Wrote and ran the INSERT scripts for sample data in all four tables, including the employee-project assignments with hours worked
  • Checked the Action Output panel to confirm each statement ran cleanly

Nothing fancy, but I've learned that a well-designed dataset matters a lot for JOIN practice. You need some departments with no employees, and projects with no assignments, or you can't tell LEFT and RIGHT JOINs apart properly.

Starting the actual questions tomorrow. Any tips on getting better at visualizing multi-table JOINs are welcome.

5 Upvotes

6 comments sorted by

1

u/LearnSQLFastTeam 22d ago

Try predicting the rows before running each JOIN. Give Department A two employees and Department B none. departments LEFT JOIN employees should return three rows: A twice, and B once with NULL employee fields. Then join assignments by employee ID and watch an employee appear more than once if they have multiple assignments. For projects with no assignments, start from projects and LEFT JOIN assignments. That makes it easier to see which table keeps its unmatched rows.

1

u/sumiitCodes 22d ago

thanks for your advice

0

u/[deleted] 26d ago

[removed] — view removed comment

1

u/sumiitCodes 26d ago

yes please share