What’s The Difference Between a Database Schema and Database User?
When I first joined the tech industry I was starting from scratch. My background was finance so no comp sci degree, no coding bootcamp, nada. Google was my friend during this time (and very much still is).
There were a lot of concepts that clicked after a quick Internet search and others….not so much. “What is a database schema?” was one of the ones I was scratching my head about for a bit.
“So what is a schema exactly and how is it different from just my database…?”
“Why did they have to choose such an unintuitive word?”
“Great now I’m 3 articles deep into learning about database objects and turns out there are things I have to worry about other than just tables”
“So how is this different from just a database user and why can’t we just use that word? Sounds like it would make things a whole lot easier”
Right when I thought I got a grasp of it another question would pop in my head. Two steps forward one step back. It was all the more embarrassing not really understanding this while working for the largest database company in the world…
So in this article today I’m hoping I wasn’t the only one hitting their head against the wall with this one and will lay out what exactly a database schema is and how it relates to the rest of the database!
So What Is a Database Schema?
It will probably be helpful to break this down piece by piece. Let’s start with what the general word schema means.
A schema is just a blueprint. It’s a structured framework or representation of anything. If you were to organize something in a way that has a logical to it, you can call it a schema.
For example let’s take a plate of food.
You’ve got your meat, your carbs, and your veggies on your plate all nice and organized. There is an order here. Asparagus isn’t sticking out of your steak and everything isn’t blended together like a mush. It makes sense, others can understand it, and it’s repeatable. You can think of the way the food is organized on the plate as a schema of a meal.
A database schema is the organization of data in a database. The easiest way to think of it is in terms of database objects. Database objects are the different types of “things” you have in your database. Examples include:
Tables - the basic way to store data. A grid organized into columns and rows just like an Excel spreadsheet
Views - custom tables you can create from parts of one or more tables. Helpful for focusing on only certain areas of your data.
Constraints - rules you can set on the data in your tables
Triggers - code that executes if a specified event occurs in your database. “If X occurs do Y”