SQL for Data Analytics · Building and changing tables

Building and changing tables

This unit

Every database you've queried so far was built by someone else. In this unit you build your own. You create a database and its tables, put rows in them, and change both the rows and the tables. Then you add constraints, the rules a database enforces so that some kinds of bad data can't get in.

The boxes in this unit's lessons run on a MySQL server of your own, in your browser. In the videos I use one on my computer, through Workbench. The first lesson starts with how it works.

The lessons:

  • CREATE, ALTER, DROP (32 min). Creating a database and its tables, choosing data types, and changing or removing a table.
  • Changing the data (25 min). Putting rows into a table with INSERT, changing them with UPDATE, and taking them out with DELETE.
  • Constraints (41 min). NOT NULL, UNIQUE, PRIMARY KEY, and FOREIGN KEY, and what happens when a statement breaks one.

When you've finished the lessons, do the Practice. It's fifteen questions in three parts, each in a database you create: an animal shelter, a restaurant booking service, and a car dealership. This is what you turn in on Canvas.