Tables

Introduction to SQL with AI

Jasmin Ludolf

Senior Data Science Content Developer

The FROM clause

SELECT product_name
FROM products;
  • FROM runs first
  • Tells the server what table to explore
  • Ask to look at a different table within prompt
  • Databases contain multiple tables
Introduction to SQL with AI

The data

Person shopping digitally and receiving orders

Introduction to SQL with AI

The data

Database with four tables to help us learn SQL: customers, products, and orders

Introduction to SQL with AI

Relational database

Customers and orders tables linked on customer_id

Introduction to SQL with AI

Relational database

Listing three tables in a quick view: customers, orders, products

$$

Understanding database structure helps to:

  • Write better prompts
  • Verify the SQL
Introduction to SQL with AI

Tables

$$

$$

  • Contain rows and columns

$$

Tables with rows and columns

Introduction to SQL with AI

Records

$$

$$

Rows:

  • Known as records
  • Individual data

$$

Table rows known as records

Introduction to SQL with AI

Fields

$$

$$

Columns:

  • Known as fields
  • Describe data parts

$$

Table columns known as fields

Introduction to SQL with AI

Querying the orders table

Prompt: What are the order IDs in the orders table?

OR

Show me the order ids from the orders table

SELECT order_id
FROM orders;

$$

  • Prompts can be questions or statements
Introduction to SQL with AI

Relational database advantages

Relational database

Introduction to SQL with AI

Relational database advantages

Combination of the orders and customers tables with repeated info highlighted

Introduction to SQL with AI

Relational database advantages

Combination of the orders and customers tables with gaps highlighted

Introduction to SQL with AI

Relational database advantages

Database with four tables to help us learn SQL: customers, products, and orders

Introduction to SQL with AI

Relational database advantages

$$

Relational database

$$

  • Efficient, organized system
  • Easy to query
  • Verify queries are looking at the right data
  • Makes more complex analysis possible
Introduction to SQL with AI

Let's practice!

Introduction to SQL with AI

Preparing Video For Download...