-
Notifications
You must be signed in to change notification settings - Fork 59
Lesson 15 (SQL Part 2)
Courtney Frey edited this page Apr 14, 2022
·
2 revisions
- More details behind one-to-many table relationships.
- The MySQL syntax for establishing primary and foreign keys.
- The difference between simple and complex SQL queries.
- How to code SQL subqueries.
- Check with your course manager for any important announcements.
- Graded Assignment #4 covers the material from Classes 14-17. Encourage the students to use their new SQL skills to start setting up the database and tables for the assignment.
- Welcome to Days 23 & 24!
-
Day 23:
- Lesson 15
-
Day 24:
- Introduce Assignment 4
- Assignment 4 work day
- Assignment 4 due end of Day 32.
- Graded Assignment #4 covers the material from Classes 14-17. Encourage the students to use their new SQL skills to start setting up the database and tables for the assignment.
- Review one-to-many relationships, and provide some practical, real-life examples.
- The book references one-to-one and many-to-many relationships but does not go into detail. Provide some scenarios and examples for situations that use these relationships.
- It would be helpful to give a live-coding example in MySQL Workbench for setting up a foreign key.
- The book showed how to place a subquery inside a
WHERE
clause. Discuss the other alternatives for placing a subquery inside a SQLSELECT
command. Provide examples!- When used in a
FROM
clause, the subquery must be given an alias.
- When used in a
- As time permits, discuss adding subqueries to
INSERT
andUPDATE
statements. - Joins and subqueries are both abstract concepts, and some students may see them as accomplishing the same thing. Spend some time discussing:
- The differences between joins and subqueries.
- When to use one approach over the other.
- How to use a join and a subquery.
- Review the studio!
- Remember to check in with each of your students. A good time to check-in today is during the warm-up SQL query tasks.
- Just like SQL part 1, the students will need to make a new model, create tables, and download and import data. Be ready to provide reminders and troubleshooting for anyone who struggles with this process.
- If a student keeps getting error messages during the warm-up tasks, they may have set up their tables incorrectly. Have them
SELECT * FROM table_name
to verify this. - If a student is struggling with setting up a subquery, ask them how they would accomplish the task using a sequence of simple queries. From there, ask guiding questions to help them combine the separate steps into a single SQL statement.
- Many times, issues with subqueries result from syntax errors (e.g. missing parentheses) rather than keywords.
- Students should not move on to the check-out and check-in library tasks until they have successfully completed the warm-up queries.