Course contentsShow
← Data Science
Lesson 846 of 2,14522. SQL FoundationsFree lesson

Tables, Schemas, and Data Types

Understanding table structure, schemas as organizational containers, and common data types for columns.

Tables, Schemas, and Data Types

What You'll Learn

You'll understand how databases organize information into tables, how schemas group those tables, and which data types define what goes in each column.

Understanding Tables

A table is like a spreadsheet in a database—it stores data in rows and columns. Each row represents a single record (like one customer or one transaction), and each column represents a specific attribute (like name, date, or amount).

For example, a customers table might have columns for customer_id, first_name, last_name, and email. Each row would contain data for one customer.

What Are Schemas?

A schema is an organizational container that groups related tables together. Think of it as a folder system for your database. In a company database, you might have:

  • A sales schema containing tables like orders, invoices, and payments
  • A marketing schema with campaigns, leads, and conversions

Schemas help keep large databases organized and set permissions (who can access what).

Common Data Types

Each column in a table must have a data type that defines what kind of information it can hold:

  • INTEGER or INT: Whole numbers (e.g., customer count, age)
  • FLOAT or DECIMAL: Numbers with decimals (e.g., prices, percentages)
  • VARCHAR or TEXT: Text strings (e.g., names, descriptions)
  • DATE, DATETIME, TIMESTAMP: Date and time values
  • BOOLEAN: True/False values

Choosing the right data type ensures data accuracy and efficient storage. You wouldn't use TEXT for storing prices or DATE for storing names.

Key Takeaway: Tables are the fundamental structure in relational databases, schemas organize tables into logical groups, and data types define what each column can contain—together they create a well-structured, efficient database.