Learning Objectives
Following this session students should be able to:
- describe the advantages of relational databases
- write basic queries including aggregation and join statements
- set up a local MySQL database and access it through a client
- add a table, and create a view in the MySQL database
- understand the data -> MySQL -> R workflow
Reading
Lecture Notes
- Configure MySQL Workbench
- Discussion: why (or why not) SQL?
- Configure local MAMP database - your own data server!
- Import the Bee Lab database to your local MySQL
- SQL queries revisited
- Exercise 1: join & aggregate
- Datatypes and table structure in MySQL
- Views, Constraints, and Indexes
- Creating a table from CSV
- Transactions & MySQL Dump files
- Full circle: query local db from R
Exercises
-- Aggregated Join --
Using the BeeLab database, write a query that displays the total number of bee individuals sampled on each soil type. Save this query file as
[click here for output]individuals_per_soil_type
.