Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Database Foundations Manipulating Schema with SQL Removing Databases

What's the main difference between database and schema?

I would like to understand the main difference between databases and schemas.

2 Answers

geoffrey
geoffrey
28,736 Points

Hey there, I didn't know the answer, but I found that one here

The answer is this one :

A database is the main container, it contains the data and log files, and all the schemas within it. You always back up a database, it is a discrete unit on its own.

Schemas are like folders within a database, and are mainly used to group logical objects together, which leads to ease of setting permissions by schema.

Thanks a lot!

Tommy Choe
Tommy Choe
38,156 Points

I know this an old post but I'd thought I'd share what I found so that others may benefit.

Apparently, in mySQL there is no real distinction between a database and schemas. They are used interchangeably. Whereas in some other languages, there is a clear distinction between them. In simple terms, schemas are pretty much a collection of tables and databases are collections of schemas.