Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

SQL & Analytical Warehousing

Progress0/29
x

Understanding Data

  • What is data?8m
  • What is a database?8m
  • Tables, rows, and columns10m
  • Primary keys and foreign keys10m

Relational core

  • Relational basics8m
  • NULL handling10m
  • Aggregations & grouping10m
  • Multi-table joins12m
  • Subqueries & CTEs10m

Windows, cleaning & opsPreview

  • Window functions (the DE benchmark)Free14m
  • Data cleaning & string/date manipulation10m
  • CASE expressions10m
  • Deduplication & incremental upserts12m
  • Indexing, partitioning & optimization12m

Advanced Querying

  • Set operations: UNION, INTERSECT, EXCEPT10m
  • Recursive CTEs for hierarchical data12m
  • Querying semi-structured JSON12m
  • Pivoting and unpivoting12m

Warehouse & Dimensional Modeling

  • OLTP vs OLAP mental model10m
  • Star schema: facts, dimensions, grain14m
  • Surrogate keys & conformed dimensions12m
  • Slowly Changing Dimensions Type 1 / 2 / 316m
  • Additive, semi-additive, and non-additive facts12m
  • Normalization vs denormalization for analytics12m

Performance & Production SQL

  • Query plans: hash, merge, nested-loop14m
  • Partitioning & clustering in real warehouses12m
  • Views vs materialized views10m
  • PK / FK / CHECK, and how warehouses relax them12m
  • Capstone: model a star from orders18m
Back to track
  1. Learn
  2. SQL & Analytical Warehousing
  3. Understanding Data
  4. Tables, rows, and columns

Lesson 3 of 29 · Theory first, then run it

Tables, rows, and columns

sqlbeginner10 min

Overview

A table has columns (properties) and rows (records). Each column has a data type. Each row is one instance.

On this page7 sections›
  1. 1The idea
  2. 2Why this exists
  3. 3Picture this
  4. 4A small example
  5. 5Common beginner questions
  6. 6What comes next
  7. 7Practice

The idea

A table is a grid of data inside a database. Columns run vertically and define the properties being stored (order_id, price, status, date). Rows run horizontally, and each row is one record (one order, one customer, one payment). Together, columns and rows form the structure that makes data queryable.

Every column has a data type that controls what values it can hold. VARCHAR stores text (like names or order IDs). INTEGER stores whole numbers (like quantities). DECIMAL or FLOAT stores numbers with decimal points (like prices). TIMESTAMP stores dates and times. BOOLEAN stores true/false values.

Why this exists

Data types are the first line of defense for data quality. If a column is defined as INTEGER, the database will reject the text value 'hello'. This prevents bad data from entering your tables. If you try to add two text strings that happen to look like numbers, the result will be wrong unless the column type is numeric.

Understanding tables, rows, and columns is essential because every SQL query operates on this structure. SELECT chooses which columns to return. WHERE filters which rows to keep. GROUP BY creates buckets of rows. All SQL thinking starts with: what does one row represent?

Picture this

The orders table: columns and rows
order_id (VARCHAR)order_total (DECIMAL)order_status (VARCHAR)created_at (TIMESTAMP)ORD-001149.00paid2026-08-01 10:15:00ORD-00242.50cancelled2026-08-01 11:30:00ORD-00388.00paid2026-08-02 09:00:00

Each row is one order. Each column is one property. The data type determines what operations are valid.

Choose the right type for each column so the database enforces quality automatically.

Data typeWhat it storesExample valuesCommon operations
VARCHAR / TEXTText strings'ORD-001', 'paid', 'laptop'LIKE, CONCAT, TRIM, LENGTH
INTEGER / BIGINTWhole numbers4, 1000, 0SUM, AVG, +, -, *, /
DECIMAL / FLOATNumbers with decimals19.50, 3.14, 0.08SUM, ROUND, >, <
TIMESTAMP / DATEDates and times'2026-08-01 10:15:00'DATE_TRUNC, EXTRACT, -, BETWEEN
BOOLEANTrue or falsetrue, falseAND, OR, NOT, CASE WHEN

The keyword DESCRIBE (or SHOW COLUMNS) lets you inspect a table's column names and types without looking at the data itself. This is often the first thing a data engineer does when exploring a new dataset.

A small example

Run the example below in this tab. Read the input, follow the code, then check the output matches what you expect.

SQLInspect column names and types before you query
DESCRIBE orders;

After DESCRIBE, pick the columns you need. SELECT * is fine while learning. In production, naming columns makes reviews easier and avoids pulling fields you never use.

SQLTwo columns, five rows
SELECT order_id, order_total
FROM orders
LIMIT 5;

Common beginner questions

What does one row represent?

This is the most important question in data engineering. In the orders table, one row is one order. In the payments table, one row is one payment. In the ecommerce_events table, one row is one click or page view. This concept is called the 'grain' of the table.

Can a column have missing values?

Yes. Missing values are represented as NULL in SQL. NULL is not zero, not an empty string, not false. It means 'unknown' or 'not recorded'. You will learn how to handle NULLs in a later lesson.

NULL is not zero

A NULL price does not mean the product is free. It means the price was not recorded. Treating NULL as zero in calculations will give wrong results.

What comes next

In the next lesson, you will learn about primary keys and foreign keys: the columns that uniquely identify rows and connect tables to each other.

Practice

Run Sample to see the column names and types of the orders table with DESCRIBE orders. Then complete Exercise: select only order_id and order_total from orders, limited to 5 rows.

Rate:
Was this useful?
What is a database?Primary keys and foreign keys