
What we will cover in this course
Install a local PostgreSQL server on Windows by downloading the version 12 Windows installer, creating a Posterous user with a password, and using PGT admin to manage the database.
Learn how to create and drop databases, switch connections, and create and drop schemas, including using the public schema and introspecting schemas for organized table groups.
Create tables in database schemas by defining columns, data types, and primary keys; switch schemas, drop with cascade, and implement foreign keys referencing user info and event info tables.
Alter tables to add, drop, or modify columns in the user info table, such as adding a region column with a char(20) type and later resizing to bigint.
Editing data in your database
create a table from a query result using 'create table as select', with column types inferred from the results and optional if not exists to avoid clashes.
Learn to use aliases for column and table names, apply the as keyword, and order results with order by, including ascending and descending orders and column position references.
Filter the track table with a where clause to find songs by composer such as AC DC, using operators =, <=, >=, <, and > on milliseconds.
Learn how to filter for null values in SQL using is null and is not null, applying these checks to a track table and composing accurate where clauses.
Learn to cast data types to convert integers to real numbers for decimal results, using cast as data type and the :: data type syntax on values or columns.
Trim and standardize strings in SQL with ltrim, rtrim, and trim to remove unwanted characters, apply upper or lower case, and cast between text and numeric types.
Measure string length, bucket name lengths with case statements, and locate positions with position, using ilike for case-insensitive searches in composer data.
Explore string replacements in sql by using the replace function to format timestamps, convert timestamp to text, and standardize date formats across databases.
Learn to use time intervals in SQL to compute date differences, add durations to timestamps, and filter data by last week or seven days.
Apply group by to compute aggregations per composer and album, counting tracks and averaging lengths. Use where and having to filter grouped results and order by counts.
Learn how to access data in other rows with window functions, using lead and lag to compute next invoice dates and time differences, including partitioning by customer.
Learn to split data into equally sized buckets using the ntile window function, partitioned by customer and ordered by invoice date, and assign a bucket number for analysis.
SQL is the language that you can use to interact with one major database type (SQL databases), one that is very wide-spread in today's world.
Knowing SQL will give you a nice ability and understanding of how to handle data and databases, and being able to integrate it into Python code enables you to create great, dynamic, and automatic systems that combine the power of programming and data.
In this course we'll be learning SQL. We'll start by going through some fundamental knowledge like learning about the relational model, as well as what schemas are, the different data types available, and how database tables are organized. Then we'll go ahead and set up our own local Postgres database and populate it with data so that we have data to run queries against. Once our setup is done we're then ready to directly jump into writing SQL code.
We'll start with the basics like creating databases and tables, inserting and selecting data, and performing filtering and result ordering. This way we can make sure we're comfortable with how the data is laid out and that we feel good performing the basic operations that usually make up all queries.
Then we'll jump deeper into SQL by learning about aggregations, subqueries, joins, unions, and window functions.
By the end of this course you should be ready to successfully apply your SQL knowledge in both technical interviews as well as on the job.