Schema vs Table vs Database: What Is the Difference?

A database holds schemas, a schema holds tables, and a table holds rows. The three are containers nested inside each other, not competing ideas.

A table stores data. A schema is a named folder that groups tables and other objects.

The three levels

LevelWhat it isWhat it containsExample name
DatabaseThe whole storage unit, with its own users and settings.Schemasshop
SchemaA named group inside a database.Tables, views, indexes, functionssales
TableA grid of rows and columns.Rows of dataorders

The full name of an object reads from the outside in. In PostgreSQL you write shop.sales.orders.

Most queries leave the first two parts out. The connection already names the database, and a search path fills in the schema.

What a table is

A table is a grid. Each column has a name and a data type. Each row is one record.

order_idcustomer_idamountstatus
1011250.00shipped
1022150.00pending

A primary key marks the column that identifies each row, here order_id. A foreign key points at a row in another table, here customer_id.

Tables are the only objects in this list that store data. A schema stores nothing on its own.

Creating one inside the other

Three statements show the nesting clearly.

CREATE DATABASE shop; CREATE SCHEMA sales; CREATE TABLE sales.orders ( order_id INT PRIMARY KEY, customer_id INT NOT NULL, amount DECIMAL(10,2), status VARCHAR(20) );

Drop the schema and every table inside it goes too. Drop a table and the schema stays.

The word schema has three meanings

This is where the confusion starts. The same word is used for three different things.

MeaningWhat people meanWhere you hear it
A namespaceA named container for tables inside a database.SQL code, permissions, CREATE SCHEMA
A table schemaThe column names, types and constraints of one table.DESCRIBE orders, migration files
A database schemaThe whole design: every table, key and relationship.Design reviews, ER diagrams

The third meaning is a blueprint, not an object you can create. When a course says the schema is the design of the database, that is the meaning it uses.

The first meaning is the one your SQL client enforces. Both are correct in their own setting.

Each engine treats schemas differently

This difference causes real bugs when moving code between systems.

EngineHow a schema behaves
PostgreSQLA real namespace inside a database. Each database can hold many schemas. The default one is public.
SQL ServerSame as PostgreSQL. The default schema is dbo.
OracleA schema equals a user. Creating a user creates that user's schema.
MySQLSCHEMA is another word for DATABASE. There is no level between them.
SQLiteNo schemas at all. Attached database files serve a similar role.

So in MySQL, schema and database mean the same thing. In PostgreSQL they do not. Read any comparison with the engine in mind.

Why teams use schemas

Splitting one database into schemas costs nothing and solves four problems.

  • Name collisions. Two teams can each own a table called events.
  • Permissions. You can grant read access to one schema instead of listing every table.
  • Separation by area. sales, billing and audit keep related tables together.
  • Tenant isolation. Some products give each customer a schema inside one shared database.

The cost is that queries and migrations must be schema aware. A missing search path setting sends a query to the wrong table.

How to Prepare

TAGS
System Design Interview
CONTRIBUTOR
Arslan Ahmad
Arslan Ahmad
ex-FAANG engineering manager and author or Grokking series.

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
Which language is preferred in FAANG?
What Is the Adobe Interview Process Like? (Round by Round)
Adobe's loop: an assessment mixing coding with CS-fundamentals MCQs, an ownership-probing hiring manager screen, production-quality coding rounds, and values-based behavioral evaluation.
What is the technical architecture of zoom?
What is IP and router?
What is a software developer portfolio?
What is the highest salary of Dell?
Related Courses
New
Grokking the AI System Design Interview course cover
Grokking the AI System Design Interview
Learn to design AI systems the way interviewers expect: classic ML products, LLM and RAG architectures, and agentic systems, all through the lens of the system design interview.
4.6
(3,192 learners)
Discounted price for Your Region

$123

Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
4.1
Discounted price for Your Region

$72

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.