Intro to SQLfor Organizing
Subsection 3.2

Reading the schema

~5 min

Reading

The schema tells you what is inside a table.

A schema usually shows:

  • Field name: the column name.
  • Type: the kind of value in that column, such as string, integer, date, timestamp, boolean, or numeric.
  • Mode: whether the field is nullable, required, or repeated.
  • Description: optional notes about what the field means.

The schema is your first defense against bad SQL. It helps you avoid guessing column names. It also helps you choose the right kind of filter.

For example:

  • If a field is a string, you usually wrap filter values in quotes: WHERE age_bucket = '18-29'.
  • If a field is numeric, you usually do not wrap the value in quotes: WHERE age >= 18.
  • If a field is a date, you need to pay attention to date format.
  • If a field is nullable, some rows may have missing values.

In the SQL warm-up from the slide deck, learners inspect the table:

prj-training-ao7c.voterfiles.voterfile_snapshot

The warm-up asks:

  • How many columns?
  • How many rows?
  • What data types do we have?
  • What is the disk size of the table?

Those questions train you to read the table before trusting it.

Learner action

Open your table's Schema tab. Find:

  • One identifier column.
  • One date or timestamp column.
  • One location column, if available.
  • One field that may help answer your organizing question.

Click on your table in the Explorer panel. Three tabs appear: Schema · Details · Preview. Start with Schema : it tells you what columns exist before you query anything.

Schema columnWhat it tells youWhy it matters
Field nameThe exact column identifier you'll use in SQL.Copy these exactly : including underscores and capitalization.
TypeSTRING, INTEGER, FLOAT, BOOLEAN, DATE, TIMESTAMP, GEOGRAPHY, RECORD.You filter and compare differently for each type.
ModeNULLABLE, REQUIRED, REPEATED.REPEATED means an array of values : you'll need UNNEST for it (beyond this course).
DescriptionA short comment from whoever loaded the table.When present, often the single most useful field on the page.

Fast column count

Click the Select All checkbox at the top of the schema grid. The status bar at the bottom shows "X of X columns selected." That's your column count : useful when the table has 100+ fields, like a voterfile.

Schemas tell you which columns exist and what type each one is. voter_file has an age column : an INTEGER : which means you can compare it with > or <. Try filtering by age.

Action: Open the Schema tab. Click Select All. Note your column count. List three field names most relevant to your Module 1 question and their types.