Skip to content

Latest commit

 

History

History
63 lines (46 loc) · 3.62 KB

Lesson1.md

File metadata and controls

63 lines (46 loc) · 3.62 KB

Lesson 1: Retrieving Data

In this class, students will be introduced to relational data terminology (row, column), the function of a primary key, and retrieving data from a MySQL database using SELECT queries.

Objective: Students should be able to retrieve data from a database table using SELECT statements that include WHERE, GROUP BY, and ORDER BY.

Pre-Class Readings

Main Topics

  • The relational model of data
  • A 'database' vs. a 'DBMS' (database management system)
  • The concept of a schema
  • The properties of an 'entity' (or 'row')
  • Basic entity relationship diagrams
  • A basic SELECT statement
  • Constructing more complex SELECT statements
  • JOIN
    • Selecting composite data from multiple tables
    • Compare JOIN WHERE with cartesian product
  • Naming Conventions: UpperCamelCase/PascalCase, lowerCamelCase, snake_case, hnHungarianNotation/HNHungarianNotation
  • Character Sets in Databases (hint: always use UTF-8 encoding, called 'utf8mb4' in MySQL)

Reference Material

Homework

Design queries that retrieve the following data sets. Compare with classmates to see if your answers were correct.

  • Find out how many todo items are on the list
  • Find all the todo items that are marked as done
  • Find all the todo items that are not marked as done
  • Get all the todo items, sorted with the most recent first
  • Get the single most recently added todo item
  • Get all todo items about 'databases'

Build a simple Node application to connect to the class database (using require('mysql')). Run the above SQL statements through your Node app (either command-line input or hard-coded) and print the results on the command line.

Watch the previous session recorded on video here:

Part 1 : https://www.youtube.com/watch?v=NbB-EXAdKks&t

Part 2 : https://www.youtube.com/watch?v=yN5XyVSUj8k&t=4055s