- 
                Notifications
    You must be signed in to change notification settings 
- Fork 60
Lesson 15 (SQL Part 2)
        Sally Steuterman edited this page Jul 28, 2020 
        ·
        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.
- 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.
- Check with your course manager for any important announcements.
- 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 WHEREclause. Discuss the other alternatives for placing a subquery inside a SQLSELECTcommand. Provide examples!- When used in a FROMclause, the subquery must be given an alias.
 
- When used in a 
- As time permits, discuss adding subqueries to INSERTandUPDATEstatements.
- 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 shoulder-surf 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_nameto 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.