So the next couple of videos are all about tables, which are the most important part of SQL.
They are the true heart of using SQL.
And in this first video, we'll start off by setting the stage or setting the table, if you will.
Let me get away with that for how they work, what they are, and then we'll dive into data types next,
and then we'll actually create tables and see the code that you use to create them.
So let's get started.
The first thing you should know is that a database is just a bunch of tables, so we've already created
a couple of empty databases and deleted them as well.
But what goes in them are just a bunch of tables.
That's where the data is stored.
As a short aside, this is in a relational database, so everything we're talking about that uses SQL,
things like my SQL PostgreSQL, those are relational databases, and they use tables, they use tabular
data, but not every single database in the world does, and we'll see some examples of those later
on.
This course is not about those types of databases, but it helps to kind of bring them in to show you
some contrast to what you're learning.
So we'll see that later on.
Just a short caveat there.
So tables hold the data.
That's my definition.
If you want the boring Wikipedia definition, it looks like this.
Tables are a collection of related data held in a structured format within a database.
Hopefully you're still awake after that.
But let's take a quick example using cats.
So we're going to model some cats data using a table.
So let's take a quick look at the cat's table.
Drumroll, please.
Dumped it or dumb?
I know.
It's pretty hilarious.
You're probably falling out of your chair.
All right, so the real cats table, at least in this context, doesn't have an apostrophe.
Look, something like this.
And of course, there's a million different ways we could break down the data for a cat from modeling
cats.
In my case, I just went with name, breed and age so we could do plenty of other things, like location,
gender is spayed, is neutered, that sort of thing.
But just doing name, breed and age.
So I've put a couple of cats in here.
We've got Blue, who's a Scottish foaled, who's one year old.
That's my cat.
We've got Rocket, who is a Persian, who is three years old, totally made up Monty, who's a tabby
who is ten years old.
That is my childhood cat.
He's still kicking and biting people.
We've got Sam, who is a munchkin.
If you don't know what that breed is, look them up.
They're pretty hilarious, although kind of sad.
They have really stubby legs, who is five years old, also made that cat up.
So some terminology.
When we're talking about tables and you hear the term columns, it's referring to the headers on that
table.
So what are the different components of data, the different pieces that have to be there?
In our case, we have name, breed and age.
So those are the columns, and then the rows are the actual data in the table.
So here's a row blue.
The cat is one row, rocket is another row.
Monty is another row.
Sam is another row.
I really wish that was lined up correctly, but I just drove myself nuts trying to get it to work.
Please forgive me anyways.
So databases are made up of lots and lots of these tables.
It's usually not just one.
If you have a really, really simple app and you're just storing one thing, then it will just be one.
But usually apps are pretty complicated and data is complicated.
All that we modeled there was cats.
But imagine if this was actually an app, let's say it was a pet sitting app.
And cats were one thing that we had to keep track of.
But we also have to keep track of owners and the pet sitters and addresses and dates and appointments
and payments.
And those are all going to be tables.
Some of them might even be multiple tables, but for now we're not going to really worry too much about
that.
But just to show you, sometimes it does get crazy.
You can click this link or I'll click it, follow my own instructions.
To see the breakdown of some of the tables that Facebook's database or a social network might use in
their database.
So this is not actual this is not 100% accurate.
There are things that are missing or incomplete.
But this just shows all the different tables, or at least some of the different tables involved in
a pretty complex app.
So as you can see, there is a bunch of them here, things like account and event and message and notification,
website, screen, name, address, blah, blah, blah, all these different things to take into consideration
so things can get messy.
And as we progress in this course, you will start working with multiple tables.
You'll see how they connect.
But we haven't even seen how to create a single table yet, so we're going to focus just on individual
tables and then we'll move on from there.