{"id":"code-col-sql-join-row-count-practice","audience":"college","category":"coding","track":"coding","technique":"examples","title":"Make JOIN practice questions from a tiny sample database","free":false,"task":"Make yourself 3 practice questions on the sample data, each 'How many rows does this return? `<query>`' with a one-line query in backticks: one INNER JOIN, one LEFT JOIN, and one LEFT JOIN ... WHERE e.student_id IS NULL. Then a line 'Answers' and 3 numbered answers like '3 rows - reason under 12 words'. No code blocks, under 140 words.","materialLabel":"The sample database from lecture (attached to your prompt automatically)","material":"CS 3200 Databases - Lecture 7 sample data (SQLite)\n\nstudents\n  id | name\n  1  | Ana\n  2  | Ben\n  3  | Cy\n\nenrollments\n  student_id | course\n  1          | CS101\n  1          | MA201\n  2          | CS101\n\nNotes from lecture:\n- INNER JOIN keeps only rows with a match on both sides\n- LEFT JOIN keeps every row from the left table; missing right side = NULL\n- \"anti-join\": LEFT JOIN ... WHERE right.key IS NULL finds rows with NO match\n- RIGHT JOIN isn't supported in older SQLite, don't worry about it\n- a student with 2 enrollments appears twice after a join!\n\nQuiz 3 is next Tuesday. Prof. Ndiaye: \"you'll get small tables like\nthese and have to say how many rows a query returns.\"\n\nMy weak spot: I always forget that one student can show up more\nthan once after a join.","rules":[{"type":"questionCount","count":3},{"type":"codeBlocks","count":0},{"type":"maxProseWords","max":140}],"mistakes":[{"title":"Random question types","why":"The AI writes 'explain the difference' questions instead of the row-count ones your quiz uses.","fix":"Show it: \"How many rows does this return? `SELECT ... FROM students s JOIN enrollments e ON ...`\".","checks":["r0"]},{"title":"Missing the join types","why":"The AI may skip the anti-join, which the quiz will likely include.","fix":"Add: \"One INNER JOIN, one LEFT JOIN, one LEFT JOIN ... WHERE e.student_id IS NULL.\"","checks":["r1"]},{"title":"Answers without reasons","why":"A bare number doesn't show why Ana appears twice.","fix":"Add: \"Answers like '3 rows - reason under 12 words'.\"","checks":["r2"]},{"title":"Too many, or code blocks","why":"The AI writes 10 questions with SQL in code blocks.","fix":"Add: \"Exactly 3 numbered questions, one-line queries in backticks, no code blocks.\"","checks":["questionCount","codeBlocks","maxProseWords"]}],"promptHints":[{"label":"Sets the number of questions","patterns":["\\b(3|three)\\b.{0,20}question"]},{"label":"Shows the question shape","patterns":["how many rows","backtick","one.line"]},{"label":"Names the join types","patterns":["inner","left join","is null","anti"]},{"label":"Asks for reasons","patterns":["reason","why"]},{"label":"Separates the answers","patterns":["answers","at the end"]}],"hint":"Practice should look like the quiz and hit your weak spot. Tell the AI the question shape, which joins, and how to show answers.","rubricLabels":["Every question is written as 'How many rows does this return?' followed by a one-line query in backticks that uses the students and enrollments tables","Question 1 uses INNER JOIN, question 2 LEFT JOIN and question 3 LEFT JOIN with WHERE e.student_id IS NULL (or the same anti-join on the enrollments key)","After a line 'Answers', the 3 answers are 3 rows (INNER), 4 rows (LEFT) and 1 row (anti-join), each followed by a short reason"]}