Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davestead's avatar

Your understanding of what a MySQL schema is?

I learned MySQL schema as the "database" that contains tables inside of the "database server" (which is the connection 'host' in PHP MySQL code), but there's seems to be multiple (mis?)understandings of what "schema" means as opposed to "database" (which is apparently already ambiguous).

So say I have a MySQL host 127.0.0.1 named localhost, which contains multiple "databases" or "schemas" (made using CREATE DATABASE) that each have their own tables; I was taught and have generally heard that "schema" was the specific name for each of those "databases" inside of the "host/server database".

It can be confusing but some people know what I'm talking about when I say "schema", some don't, some people think I mean the server or the database/schema when I say "database"... there just seems to be a terminology issue, but I just discovered that MySQL Workbench (made by the MySQL/Oracle people) refers to each "DATABASE" inside of the server database as the "schemas":

https://imgur.com/PYascR5 (I don't know how to paste/attach a screenshot here)

So I'm going to fall back to the MySQL people and consider a "schema" to mean an individual DATABASE (that contains tables) inside of the database host/server; but I'm curious what you think or how you use the terminology, and maybe there needs to be clarification.

0 likes
16 replies
D9705996's avatar

A simplistic (database agnostic) definition is that a database is a collection of tables, each table contains records and a record has fields of data.

A schema is the definition of how the database is structured e.g. it has a users table, each user has a username, the username is a varchar with max length 45 and must be unique

https://en.m.wikipedia.org/wiki/Database_schema

davestead's avatar

@ADAMPRICKETT - If a schema refers to a table-containing DATABASE rather than a server/host database, why use the ambiguous "database" to refer to a table-containing schema?

davestead's avatar

@D9705996 - OK, so if a schema refers to the blueprint of a table-containing database, then doesn't that schema have a name? Like a database named client_info would have tables named users and addresses, and its schema would be the blueprint of the client_info table (its tables structure), wouldn't it still be less confusing to call it a schema instead of a database which can also refer to the host/server?

If I'm going off MySQL Workbench's description, a schema refers to a table-containing database regardless of its blueprint or structure.

Also, I was going through a Laravel issue I'm having, and found another reference to table-containing databases being called schemas:

https://medium.com/@ashokgelal/a-full-featured-multi-tenant-app-with-laravel-part-1-4049a3cc229d

*"If you don’t have it already, download and install SequelPro. Connect as root to your local MySQL server and create a new database name townhousedb.

Create a new user, townhouseadmin, and set the password as secret. Go to Global Privileges tab and click Check All button. Go to Schema Privileges tab and select townhousedb from schema list. Select all Available Privileges by hitting CMD+A keyboard shortcut and click < button to grant all the selected privileges. Finally, click Apply."*

At least in the MySQL world, it seems easier to call table-containing databases schemas... or at least understand what is being referred to when stating "schema" in relation to something containing tables and that doesn't make sense with it referring specifically to the host/server.

I'm really just trying to find a clear way to refer to what I'm talking about here without it causing confusion as it seems to be thought of a little differently here than elsewhere in my experience.

Dalma's avatar

Generically a schema is meta-data describing the structure of a database.

D9705996's avatar

@DAVESTEAD - As you can see from the comments, there really isn't a 100% definition of the technical differences between a database and a schema, especially as different RDMS vendors give then different meanings.

If you are looking for a laracasts defintion to help explain your problems in a discussion you won't go far wrong with

  • Database is the configured connection from config/database.php
  • Schema is the content of you migrations that are used to build the tables, indexes, foreign keys, etc within the configured database.

If you are not using migrations then it would be the output of DESCRIBE <%YOUR_TABLE%> from you mysql command line or equivalent Sequel pro (not on Mac so not sure what this is)

davestead's avatar

@D9705996 - "Schema is the content of you migrations that are used to build the tables, indexes, foreign keys, etc within the configured database."

OK, that's what I mean by schema when I'm talking about a table-containing "database" in MySQL.

In one of my posts people weren't sure what I meant when I said "schema", so that's what I meant, and I hope the Laravel community understands this the same way since that definition is coming from Laracasts.

MySQL database - server/host.

MySQL schema - table-containing "database"

D9705996's avatar

@DAVESTEAD -

MySQL database - server/host.

MySQL schema - table-containing "database"

The database is not the server/host. A database server (RDMS) is an application running on a server which can have many databases.

The schema is not a table containing the database. The schema defines the structure of each table within a specific database (for example you may have a different user table schema for different databases).

I would advise to avoid any ambiguity when posting within Laracasts to stick to Laravel specific terminology e.g. rather than saying schema use migrations and show the content of the relevant migration(s), That way 99% of people will understand exactly what you mean rather than having to interpret your own domain specific language

davestead's avatar

@D9705996 - So you're saying MySQL and Oracle are wrong? Check this image again:

https://imgur.com/PYascR5

Notice where it says "browse your database schemas" and "work with database objects"...

In "browse your database schemas", what do you think is meant by "database" and "schemas"? Do you think "database" in that context refers to "the thing that contains the tables" or do you think "schemas" means that?

In "work with database objects", what do you think "database" and "objects" mean? The same thing as "database" in the previous statement?

Their intro also says "migrate schemas and data from other database vendors"... so what do you think "schemas" and "database" means in this context? They're obviously different things, and from every migration I've ever done or read about, you migrate the data in tables contained inside "the thing that contains the tables", which I've known specifically as "schemas" and generally synonymously (and incorrectly in my opinion) as "databases".

In MySQL's own context, "database" refers to "the thing that stores the schemas that you connect to with an IP/domain that is a server that is also a host for your data", and "schemas" refers to "the thing that contains your tables".

So I'm really curious how you can explain away MySQL's own usage of the terms "database" and "schema" just in the context of their own workbench intro...

Dalma's avatar

A database is data storage and retrieval mechanism.

A Schema defines the type, format and physical location of the data. This type of data is commonly described as Meta-data (data about data). The schema data may be stored within a database or in discrete files depending on how the database was designed.

Database objects could describe any logical collection within a database such as users, permissions, user tables, schema, performance metrics, astrological signs etc

Are you seeking my insight in how to interact with a database or is this more of Computer Science 101 inquiry?

Cronix's avatar

Schema is a generic word (it's Greek) that has been used across many industries. It's not specific to databases at all. I think if you just google the actual definition (not specifically related to databases) it would be more clear. It just describes how to define the database. Just like in electronics, a schematic is the blueprint to create a circuit board, and in construction the schematic is the blueprint to build the house. The database schema describes how to build the database and tables.

  1. : a diagrammatic presentation broadly : a structured framework or plan : outline

https://www.merriam-webster.com/dictionary/schema

  1. a diagram, plan, or scheme.
  2. an underlying organizational pattern or structure; conceptual framework:

https://www.dictionary.com/browse/schema

Schema::create('flights', function (Blueprint $table) {
  // table definition... aka schema
});
1 like
D9705996's avatar

@DAVESTEAD - To be honest I think we argue about the different vendor definitions of what is a schema, database, etc and how they relate to laravel forever and isn't something I want to spend any real effort on.

You want to reduce any ambiguity when you ask for help here so all I can give you is what would help me if you start a discussion that I wanted to help with.

For 99% of times avoid the ambiguous terms completely and explain your problem in plain English, what you have tried, any errors and the relevant code as this helps more than whether its a schema, database, etc.

Laravel hides a lot of the implementation details behind interfaces/config so details like database shouldnt matter as migrations, eloquent, etc are agnostic to this detail.

Just remember that everyone here is doing so as part of a community and does so of there own free will so the harder you make it for us to help with unnecessary issues the less likely you are to get that help in the first place.

1 like
davestead's avatar

@D9705996 - No reason to argue, I'm just trying to clarify with Laravel people what is meant by MySQL 'database' and 'schema' as a conversation got derailed by people not knowing what I meant when I was using MySQL/Oracle terminology...

I shouldn't have to clarify, but that's why this thread is here, to get an idea of what is actually thought of with these terms, but it seems there's resistance to using these terms the way MySQL/Oracle uses them.

In any case I'll continue to use them as MySQL/Oracle does, as it's perfectly clear to me (non-ambiguous), makes sense, and I will simply clarify if someone gets confused. Most developers in real life have known what I meant by at least "schema" when talking about MySQL; I think "database" is too synonymous with multiple things (like server or schema), but the MySQL/Oracle people do clarify in their tool dialogues, which I'm grateful for.

jlrdw's avatar

Just curious is this more of a guide to help people.

It's under laravel but laravel is the framework, looks like more of a database thing.

Again just curious no reply is applicable.

davestead's avatar

Another example of "schemas" in MySQL as "the thing that holds the tables in the database":

https://imgur.com/ZNoy3IF

I just installed MAMP and opened up the MySQL database viewer (phpMyAdmin), and it shows me the different "schemas", when I expand them, it shows their tables.

However, the "Database" tab has a "Create Database" form, making it ambiguous again (especially since it's in a database connection), but in MySQL Workbench, right-clicking in the "databases" list (the things that hold the tables) shows Create Schema, which then lets me create another one of the things that holds the tables (which then gives me an Alter Schema option when right-clicking that).

So yes I still think I'm OK calling the things that hold the tables "schemas" and expecting MySQL users (especially PHP coders, where MySQL is the most popular database technology to use with it) to know what I'm talking about.

Hopefully we can use this to minimize ambiguity, as too often people I'm seeing people mix up what they mean or think someone means by "database".

davestead's avatar

Here's how MySQL Workbench displays "schemas" - as the things that holds the tables:

https://imgur.com/PNo18MN

If I expand a schema, it shows the tables; if I expand the tables, it shows the columns.

https://imgur.com/a/GWMhzzy

There's a button at the top that looks like a pancake stack (like the Sequel Pro app icon, which is also the icon for "database") to add a new schema:

https://imgur.com/MCOEPqU

So MySQL Workbench at least follows what I've learned in my career with other developers that a schema holds the tables (and can also refer to the table structures), and a database is merely supposed here to be a more general term that can refer to a server or the thing that holds the tables.

There's my clarification so I can refer to this permalink if someone gets confused on what I mean by database or schema.

Please or to participate in this conversation.