✌️Hello! My name is Tyler Clark and this is the source material for my Advanced SQL workshop
Let's face it, data powers the web. And I am not only talking about your twitter posts you see in your feed. I'm talking about analytics, artificial intelligence, and even weather forcasting is literally powered by data. Also, look at the rise in python over the last decade. It's recently overtaken JavaScript as the most popular programming language.
Why you might ask? To handle complex data.
This course is designed to take your basic sql CRUD (create, replace, update, delete) to the next level by learning more in-depth concepts.
Even if you classify yourself as a frontend developer, I promise you this course will help you out in some point of your career. We become better frontend developers by learning more about how data is constructed and queried.
This workshop is helpful for developers that have basic knowledge of SQL.
- Setup the project (follow the setup instructions below)
- Install and setup Zoom on the computer you will be using
While there are similarities between each lesson, we will work through each lesson mostly independently of each other.
- Bulk insert / update / export
- The insert on conflict flag
- Casting types
- Defining custom types
- Query performance tuning. Understanding the query planner by using
explain
andanalyze
- Creating Common Table Expressions (CTE)
- Filter aggregated data with
having
- Defining scopes and variables with
do
anddeclare
- Conditional returns with
case
,when
,then
,else
, &end
- Perform Multiple Steps in One with Transactions
- git v2 or greater
Git must be available in your PATH
. To verify things are set up
properly, you can run this:
git --version
If you have trouble with any of these, learn more about the PATH environment variable and how to fix it here for [windows][win-path] or [mac/linux][mac-path]
- For macs, make sure you have HomeBrew
- First I suggest cloning this repo to better follow along with the material:
git clone https://github.com/twclark0/sql-advanced.git
cd sql-advanced
- Install postgres on your machine. When it's install, make sure you can connect to your local DB by running
psql postgres
in your terminal
- Use HomeBrew
brew install postgresql
- Follow the instructions here: https://www.postgresql.org/download/windows/
- Once you have postgres running locally, run the following commands:
create table users (
user_handle uuid Primary key,
first_name text,
last_name text,
email text
);
create table purchases (
date date,
user_handle uuid,
sku uuid,
quantity int
);
create table members (
start_date date,
end_date date,
user_handle uuid,
first_name text,
email text
);
Each lesson is separated by different folders. Within each folder is a notes.md
file that holds the information we will be going through. Each notes markdown file is broken down into three main sections. This includes a general "notes", "syntax", and a "exercise" block. I will work top to bottom, starting off by giving some general notes about each lesson. This includes which versions of postgres support this concept, some common gotchas, and other tips. We'll then review its syntax and then walk through an exercise of this concept.
This material is available for private, non-commercial use under the
GPL version 3. If you have questions about using this workshop material in anyway, please contact me
at [email protected]