Skip to content

SQL and Data Preparation for AI

Get the data for an AI project out of a database, clean it, and prepare it for a model without leaking the answer. You write real SQL in the browser from the first lesson.

Read every lesson as a guest, or sign in to enroll and track your progress.

What you'll learn

By the end of this course, you will be able to:

  • Query relational data and validate joins.
  • Clean messy datasets reproducibly.
  • Detect leakage and unsuitable splits.
  • Produce a documented dataset ready for modelling.

About this course

AI projects spend much of their time on data. Before a model can learn, someone must get the right rows out of a database, find what is wrong with them, fix it and prepare training and test sets that give an honest result. Mistakes here are quiet: a join that doubles some rows or a column that contains the answer does not cause an error. It causes a model that looks good in testing and fails with real users.

This course teaches that work with one running example: the support tickets of Larkfield, a fictional online shop for home and garden products. You write SQL to query its customers, tickets and ticket outcomes, then use Python and pandas to clean the data and prepare it for a model that predicts which tickets need a senior agent. Every exercise checks its own result: row counts, totals and rules that must be true.

At the end, you deliver a validated modelling dataset: the queries and their row counts, your cleaning decisions, a leakage-safe split, and a schema and quality report that another person can check and run again.

Before you start

You completed Python for Practical AI Engineering, or you can already run a Python script from a terminal, use a virtual environment and read a CSV file. You need Python 3.12 or later. You do not need to know SQL. All tools are free, and no account is needed.

Courses to take first: Python for Practical AI Engineering.

Who this is for

People who know basic Python and want to prepare data for AI work. You do not need to know SQL or have used a database before.

How we made this course

Experienced AI practitioners designed this course. AI helped us draft the content; people chose the teaching approach and the examples, and reviewed every lesson. The outputs that you see are the actual results of running the code. How we make our courses

Inside the course

Module 2SQL essentials

3 lessons

Ask the database questions in SQL. You filter, count and join tables, and you check every result against the source so that a join cannot add or lose rows without you noticing.

  1. Select and filter45 min
  2. Aggregate correctly45 min
  3. Join tables55 min

Module 6Data contracts and handoff

3 lessons

Hand over a dataset that others can trust. You write validation rules, record where the data came from and how it changed, and run the whole preparation again from a clean start.

  1. Validation rules55 min
  2. Track lineage45 min
  3. Deliver a reusable dataset55 min

Final module · choose at least oneCase studies

3 case studies

Three end-to-end case studies on real public data. Explain a shop's sales from a raw export, build a repeatable, leak-free pipeline for city repair requests, and plan bike rebalancing from trip records. Complete at least one for the certificate; each one is a portfolio piece.

Complete at least one case study for the certificate. The others are optional. What each one covers

  1. Explain an online shop's sales150 min
  2. Prepare a leak-free table for city repair requests150 min
  3. Plan overnight bike rebalancing150 min

After the case studiesFinal assignment

Use every module in one practice project. You collect evidence, and check it against the course outcomes.

  1. Final assignment180 min

Case studies

Realistic projects from start to finish, on real data, with every output explained. Each one makes a portfolio piece. Complete at least one for the certificate; the others are optional.

  1. Explain an online shop's sales2 hr 30 min

    Turn a real shop export into tables, reconcile revenue and returns, and answer planning questions with window functions and cohorts.

  2. Prepare a leak-free table for city repair requests2 hr 30 min

    Build a repeatable pipeline from a messy NYC 311 export to a documented, leak-free modelling table.

  3. Plan overnight bike rebalancing2 hr 30 min

    Find export defects and van moves in real bike-share trips, and build a station target from earlier days only.

Reviews

Loading the reviews…

    Took this course? Sign in to review it. Learners can write a review after they complete 25% of the lessons.

    Share this course