We may earn an affiliate commission when you visit our partners.
Course image
Will Bunker

Learning SQL was one of the most valuable skills I learned while building Match. We had one of the largest instances of Microsoft SQL Server in the 90s with millions of records to keep the site running. The better we got at SQL, the better we could make the site work for our users and answers sophisticated questions about our users.

Read more

Learning SQL was one of the most valuable skills I learned while building Match. We had one of the largest instances of Microsoft SQL Server in the 90s with millions of records to keep the site running. The better we got at SQL, the better we could make the site work for our users and answers sophisticated questions about our users.

I want to teach you how to use PostgreSQL. We will walk through

  • Basic selection statements

  • Joining multiple tables together

  • Grouping records to get aggregate data

  • Inserting, updating and deleting records

  • Creating tables and indexes

  • Subqueries to create sophisticated reports

  • Table constraints to keep data clean

  • Sequences to create auto incrementing fields

  • CTE - common table expressions that include recursive queries

  • Views to simply accessing complex queries

  • Conditional Expressions for queries

  • Window functions to combine regular queries with aggregate data

  • How to work with date, time and intervals

  • Create SQL Functions to capture complex statements

  • Create PL/pgSQL Functions that allow programming with if/then and loops

  • Triggers

  • Array data types

  • Composite data types

  • Transactions and concurrency control

Enroll now

What's inside

Learning objectives

  • Perform sophisticated queries
  • Join tables together
  • Use group by to answer questions on aggregated date
  • Create and modifying tables
  • Create indexes to improve search speed
  • Put in constraints to keep data clean
  • Use pgadmin tool
  • Learn recursive queries
  • How views make accessing data simpler
  • Subqueries
  • Sequences to auto increment fields
  • Common table expressions
  • Conditional expressions
  • Window functions
  • How to handle date and time data
  • Sql functions
  • Transactions and concurrency control
  • Pl/pgsql functions
  • Triggers
  • Composite data types
  • Array data types
  • Show more
  • Show less

Syllabus

Introduction

Why learn SQL and what are the major databases.  Explains what tables, fields and rows are in the context of databases.

Install PostgreSQL, the admin tool, pgAdmin, and install Northwind database
Read more

How to install PostgreSQL using EnterpriseDB installer

How to install PostgreSQL on Windows with pgAdmin 4 and psql tools

Get up and running with PostgreSQL 11 and pgAdmin 4 on Ubuntu.

How to install Northwind database using pgAdmin using the restore feature and northwind.tar file.

Add 3 more databases to learn from.

How to select all data from table, restrict fields returned and use DISTINCT and COUNT

How to select all information from a table using simple SELECT statement.

How to return specific fields when running a SELECT statement.

If you want to find all the unique values in a specific field in table, you use the DISTINCT keyword.

Using COUNT statement to return the number of records.

How to derive information using more than one field.

Use pagila database to practice your basic SELECT.

Use Basic WHERE clauses on single tables to find records.

Learn about the WHERE clause and how it is used to narrow down the number of records returned.

How to select records based on matching text fields.

How to use WHERE with numeric fields with =, >, >=, <, and <= 

How to select records that have date fields.

Using AND to select records where all conditions must be true.

You can select records where any of the conditions are true using OR operator.

Reverse the meaning of operator using logical NOT operator.

Using parenthesis to create more complicated queries that combine logical operators.

Using BETWEEN to find values >= and <=.

If you have a long list of values the IN operator is easier to understand and read.

Use the usda resource to practice your WHERE clauses.

Learn how to group tables under a schema. How to create schemas and select tables from them.

Learn what schemas are and how to use tables that are located in schemas.

Using psql To Connect To Postgres

Use psql command line to connect to your local database and run commands.

Remove inputing connection parameters for command line tools by using environment variables, a .pgpass file, or .pg_service.conf file.

Learn how to what databases are present and connect to them in psql.

How to list the schemas and see the tables in a schema using psql.

Intermediate SELECT Statements

If you need the results to be returned in a specific order, use ORDER BY.

Find the smallest record with MIN and largest with MAX.

Use these function to find the average value or the sum of all the values.

LIKE allows you to match text patterns for partial matches.

You can change the name of a column with AS syntax.

If you only need a certain number of records use LIMIT to control.

Nulls are a special value to indicate an unknown.  Learn how to use IS NULL and IS NOT NULL to select based on NULLs.

Practice using AdventureWorks database.

How to use JOIN to query across 2 or more tables.

How to map out the tables and relationships in a database with diagrams.

How to pull information from 2 different tables in a single statement using JOIN.

Use multiple JOIN statements to pull together 3 or more tables.

Left joins allow you to pull all records from first table and any matching records from second table.

Right joins allow you to pull matching records from first table and all records from second table.

Full joins pull all records from both tables.

Connect a table back to itself.

Reduce typing with USING instead of ON in joins.

NATURAL joins combine tables where fields are named the same in each table.

Practice joins using the AdventureWorks database.

Grouping records to perform aggregate functions like average, sum, or count.

GROUP BY allows you to aggregate records and perform an aggregate function like AVG.

HAVING clause lets you filter out results of your GROUP BY results.

Use GROUPING SETS to group by multiple fields separately in a single query.

Using ROLLUP as a shortcut for complex GROUPING SET

CUBE creates all combinations of fields while grouping.

How to combine multiple queries using UNION, INTERSECT, and EXCEPT

UNION allows you to combine 2 or more queries into a single result.

Use INTERSECT to find records that are in both queries.

Use EXCEPT to only bring back records from first query that are not in the second query.

Use subqueries to pull back records that meet conditions in other tables.

EXISTS subqueries allow you to check a condition in another table as part of the criteria to return a record.

Find records that return if any or all of the subquery match the condition.

You can use a subquery with IN operator to dynamically build list.

So far we have looked at existing data. Know we will learn how to create new records, update existing records and delete records.

You will learn how to insert new data into a table.

Alter existing records using UPDATE statement.

Remove data using the DELETE statement.

Create a new table based on records returned from select statement.

Insert records into an existing table by selecting from another table.

Using RETURNING to bring back data after INSERT, UPDATE, or DELETE.

Learn how to analyze queries using EXPLAIN. See how indexes change the performance of queries.

Learn what indexes are, what they help with and the drawbacks of too many indexes.

Create indexes on tables that will result in faster searches.

Remove an existing index from a table.

Find running queries using pg_stat_activity table and cancel them with pg_cancel_backend.

We will create a large table and demonstrate how EXPLAIN works.  Then see the difference when an index is added.

Learn to use EXPLAIN ANALYZE to see actual performance versus the prediction by the query analyzer.  Use ANALYZE table_name to update the table statistics.

Learn how PostgreSQL uses calculates the query plan cost by estimated disk I/O and CPU usage for the query.

Learn how to properly use multi-column indexes. 

Make indexes on modified columns using expression indexes.

Learn about B-Tree, Hash, GIN, GiST, BRIN, and SP-GiST indexes and what situations are best for each type.

Use a GIN index with gin_trgm_ops to speed up text matching in the middle of text for LIKE '%some%' operations.

Learn the principles behind database design and commands to build tables.
Design Process Overview
Database Terminology

Learn 7 steps to go through in order to design a database.

Conduct interviews with employees and management to find out main purpose and tasks the database should support.

Learn how to analyze the current paper and database systems in a business and turn into tables and field lists.

Take the interviews and information collected in previous step and identify tables and fields that will go in new database.

Learn what makes a good primary key and how to find or create one for every table.

Document and specify all the fields in database, including descriptions, uniqueness, data type, and length.

Create a table matrix to map out the relationships between tables. Make an ER diagram to communicate to others what the relationships are.

Learn about different types of business rules and how to document them.

Learn what views are used for and how to map out needed views.

The final step is reviewing data integrity and pulling documentation into a single source.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Develops core SQL skills, which are necessary for most roles in data science
Useful for anyone who collects, manages, or uses data
Provides a thorough grounding in SQL for both beginners and experienced learners
Taught by Will Bunker, who is recognized as an expert in data science with 20 years of experience
Covers a wide range of topics, from basic SQL commands to advanced techniques such as window functions and CTEs
Includes hands-on labs and interactive materials, providing practical experience with SQL

Save this course

Save Learn SQL Using PostgreSQL: From Zero to Hero to your list so you can find it easily later:
Save

Reviews summary

Well-structured postgresql course

Learners say this comprehensive PostgreSQL course has engaging assignments with plenty of opportunities to practice queries. The course covers many major topics, and students emerge confident in managing PostgreSQL databases. One learner suggests emphasizing best practices and potential production server issues.
Course covers major PostgreSQL topics.
"it's a comprehensive course covering all the major topics on postgresql"
Engaging assignments with many chances to practice queries.
"I like that the course is taught by demonstration and then followed by practices that gives a lot of chances to try out the queries"
Learners emerge confident in managing PostgreSQL databases.
"now I can say I am more confident to manage postgres db than mysql db"
Suggestions for improvement include emphasizing best practices and potential server issues.
"A suggestion to improvement is to put more emphasis on the parts that we should pay special attention, best practices, and caveats on what could go wrong on production server"

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Learn SQL Using PostgreSQL: From Zero to Hero with these activities:
Organize and review course materials
Consolidate your notes, assignments, quizzes, and exams to enhance your understanding and retention.
Show steps
  • Gather all course materials, including lecture notes, slides, assignments, and exams.
  • Organize the materials by topic or date.
  • Review the materials regularly to reinforce your understanding and identify areas for improvement.
Read 'SQL Cookbook' by Anthony Molinaro
Supplement your learning with a comprehensive reference guide that provides practical solutions to common SQL problems.
Show steps
  • Obtain a copy of 'SQL Cookbook'.
  • Read through the chapters that cover topics relevant to the course, such as data manipulation, aggregation, and subqueries.
  • Refer to the book as needed while working on assignments or encountering specific SQL challenges.
Join a study group for SQL practice
Collaborate with peers to practice SQL queries, troubleshoot errors, and share knowledge.
Show steps
  • Find a study group or create one with classmates or fellow learners.
  • Set regular meeting times and establish a collaborative study plan.
  • Bring your own SQL queries or work on problems together as a group.
  • Share your knowledge and insights with others, and learn from their perspectives.
Three other activities
Expand to see all activities and additional details
Show all six activities
Explore advanced SQL functions using tutorials
Enhance your SQL proficiency by following guided tutorials that demonstrate how to use advanced functions for complex data manipulation.
Browse courses on SQL Functions
Show steps
  • Find tutorials that cover specific SQL functions you want to learn, such as window functions or date/time functions.
  • Follow the tutorials step-by-step, experimenting with the provided code examples.
  • Apply the learned techniques to your own sample data to reinforce your understanding.
Design a database schema for a real-world scenario
Apply your understanding of database design principles by creating a database schema that addresses a specific business need.
Browse courses on Database Design
Show steps
  • Identify a real-world scenario that requires a database, such as managing customer information or tracking inventory.
  • Analyze the requirements and identify the entities, attributes, and relationships involved.
  • Design a logical data model using ER diagrams or other modeling techniques.
  • Translate the logical model into a physical schema using PostgreSQL syntax.
  • Create the database and tables based on the designed schema.
Build a data analysis dashboard using SQL
Apply your SQL skills to create a visually engaging dashboard that presents insights from a dataset.
Browse courses on Data Visualization
Show steps
  • Identify a dataset that you want to analyze and visualize.
  • Design the layout and structure of your dashboard, including charts, graphs, and tables.
  • Write SQL queries to extract the necessary data from the database.
  • Use a data visualization tool, such as Tableau or Power BI, to create the dashboard.
  • Present your dashboard to others and discuss your findings.

Career center

Learners who complete Learn SQL Using PostgreSQL: From Zero to Hero will develop knowledge and skills that may be useful to these careers:
Data Analyst
Data analysts leverage data to solve complex business problems. Using this course, aspiring data analysts can build a firm foundation in SQL, a core skill for data analysis. The course provides hands-on training in essential SQL concepts such as data retrieval, manipulation, and aggregation, empowering learners to confidently manage and analyze large datasets. Furthermore, the exploration of advanced topics like subqueries, window functions, and CTEs equips learners with the skills to tackle more sophisticated data analysis tasks.
Database Administrator
Database administrators are responsible for maintaining and optimizing databases to ensure data integrity and availability. This course offers a comprehensive introduction to PostgreSQL, a widely used database management system. Learners will gain proficiency in core database administration tasks such as creating and modifying tables, managing indexes, and implementing constraints, providing them with a solid foundation for a career as a database administrator. Additionally, the course covers advanced topics like triggers, stored procedures, and transactions, equipping learners to handle complex database management scenarios.
Software Developer
Software developers build and maintain software applications. This course provides a strong foundation in SQL, an essential skill for software development. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively integrate data into their software applications. Moreover, the coverage of advanced topics such as subqueries, window functions, and CTEs empowers learners to handle complex data-related tasks within software development projects.
Business Analyst
Business analysts bridge the gap between business stakeholders and technical teams. This course offers a solid foundation in SQL, a key skill for business analysts. Learners will gain proficiency in extracting and analyzing data to derive meaningful insights. The course also covers advanced topics like subqueries, window functions, and CTEs, equipping learners with the skills to tackle complex data analysis tasks within business analysis projects.
Data Scientist
Data scientists use data to uncover patterns and trends, and to make predictions. This course provides a strong foundation in SQL, a core skill for data science. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively prepare and analyze data for machine learning and other data science tasks. Additionally, the course covers advanced topics like subqueries, window functions, and CTEs, empowering learners to handle complex data analysis tasks within data science projects.
Data Engineer
Data engineers design and build data pipelines and infrastructure. This course provides a solid foundation in SQL, a crucial skill for data engineering. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to efficiently manage and process large datasets. Moreover, the course covers advanced topics like subqueries, window functions, and CTEs, equipping learners with the skills to handle complex data engineering tasks.
Technical Writer
Technical writers create documentation for software, hardware, and other technical products. This course offers a solid foundation in SQL, a valuable skill for technical writers. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively understand and communicate technical concepts related to databases and data management.
IT Consultant
IT consultants provide guidance and expertise on technology-related issues. This course provides a strong foundation in SQL, a core skill for IT consultants. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and present data to clients, and to make recommendations for technology solutions.
Systems Analyst
Systems analysts design and implement computer systems. This course offers a solid foundation in SQL, a valuable skill for systems analysts. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and design database systems that meet the needs of organizations.
Database Designer
Database designers create and maintain database schemas. This course provides a strong foundation in SQL, a core skill for database designers. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively design and implement database schemas that meet the requirements of various stakeholders.
Quality Assurance Analyst
Quality assurance analysts test and evaluate software products to ensure they meet quality standards. This course offers a solid foundation in SQL, a valuable skill for quality assurance analysts. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and evaluate data related to software testing and quality assurance.
Information Security Analyst
Information security analysts protect computer systems and networks from unauthorized access and attacks. This course offers a solid foundation in SQL, a valuable skill for information security analysts. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and investigate security-related data.
Statistician
Statisticians collect, analyze, and interpret data to uncover patterns and trends. This course offers a solid foundation in SQL, a valuable skill for statisticians. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and interpret large datasets.
Market Researcher
Market researchers conduct research to understand consumer behavior and market trends. This course offers a solid foundation in SQL, a valuable skill for market researchers. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and interpret data related to consumer behavior and market trends.
Actuary
Actuaries use mathematical and statistical techniques to assess risk and uncertainty. This course offers a solid foundation in SQL, a valuable skill for actuaries. Learners will gain proficiency in data retrieval, manipulation, and aggregation, enabling them to effectively analyze and interpret data related to risk and uncertainty.

Reading list

We've selected 14 books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Learn SQL Using PostgreSQL: From Zero to Hero.
Great resource for learning the theory behind SQL. It covers a wide range of topics, from the basics of relational algebra to advanced topics like normalization and query optimization.
Comprehensive reference guide for PostgreSQL. It covers everything from the basics of PostgreSQL to advanced topics like replication and performance tuning.
Great resource for learning how to administer PostgreSQL 13. It covers a wide range of topics, from installation and configuration to advanced topics like replication and performance tuning.
Comprehensive guide to PostgreSQL, covering everything from installation and configuration to advanced topics like replication and performance tuning.
Comprehensive reference guide for IBM DB2 12 for z/OS. It covers everything from the basics of IBM DB2 to advanced topics like data warehousing and business intelligence.
Comprehensive reference guide for Oracle Database 12c. It covers everything from the basics of Oracle Database to advanced topics like data warehousing and business intelligence.
Covers a wide range of SQL topics, from basic querying to advanced techniques like using CTEs and window functions. It's an excellent resource for anyone looking to improve their SQL skills.
Great resource for learning how to improve the performance of your SQL queries in SQL Server 2016. It covers a wide range of topics, from query optimization to database design.
Handy reference guide for SQL. It covers all the most important SQL commands and syntax, making it a great resource for quick reference.
Is about improving the performance of SQL queries, both generally and with PostgreSQL more specifically.
Covers topics beyond the scope of the course. It is about administrating and maintaining a PostgreSQL database.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Learn SQL Using PostgreSQL: From Zero to Hero.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser