WEBVTT

00:00.090 --> 00:06.380
So the next couple of videos are all about tables which are the most important part of sequel.

00:06.390 --> 00:12.390
They are the true heart of using sequel and in this first video we'll start off by setting the stage

00:12.390 --> 00:19.080
or setting the table if you will let me get away with that for how they work what they are and then

00:19.080 --> 00:24.360
we'll dive into data types next and then will actually create tables and see the code that you use to

00:24.360 --> 00:25.330
create them.

00:25.350 --> 00:27.470
So let's get started.

00:27.600 --> 00:32.400
The first thing you should know is that a database is just a bunch of tables.

00:32.430 --> 00:36.450
So we've already created a couple of empty databases and deleted them as well.

00:36.750 --> 00:39.530
But what goes in them are just a bunch of tables.

00:39.750 --> 00:43.400
That's where the data is stored as a short aside.

00:43.470 --> 00:50.250
This is in a relational database So everything we're talking about uses sequel things like my Escudo

00:50.460 --> 00:56.760
postscripts sequel like those are relational databases and they use tables they use tabular data but

00:56.790 --> 00:59.120
not every single database in the world does.

00:59.190 --> 01:05.040
And we'll see some examples of those later on this course is not about those types of databases but

01:05.130 --> 01:08.970
it helps to kind of bring them in to show you some contrast to what you're learning.

01:08.970 --> 01:10.490
So we'll see that later on.

01:10.680 --> 01:12.440
Just a short caveat there.

01:13.650 --> 01:14.930
So tables hold the data.

01:14.940 --> 01:19.080
That's my definition if you want the boring Wikipedia definition.

01:19.110 --> 01:20.410
It looks like this.

01:20.520 --> 01:26.310
Tables are a collection of related data held in a structured format within a database.

01:26.310 --> 01:28.110
Hopefully you're still awake after that.

01:28.530 --> 01:32.680
But let's take a quick example using CAS.

01:33.090 --> 01:36.790
So we're going to model some cat data using a table.

01:37.060 --> 01:37.660
OK.

01:37.890 --> 01:40.760
So let's take a quick look at the cats table.

01:40.780 --> 01:42.430
Drum roll please.

01:42.550 --> 01:44.070
That or die.

01:44.970 --> 01:46.730
I know it's pretty hilarious.

01:47.160 --> 01:49.030
You're probably falling out of your chair.

01:49.620 --> 01:49.950
All right.

01:49.950 --> 01:55.200
So the real cats table at least in this context doesn't have an apostrophe.

01:55.380 --> 01:56.680
Look something like this.

01:56.700 --> 02:02.530
And of course there's a million different ways we could break down the data for cat for modeling cats.

02:02.670 --> 02:06.730
In my case I just went with a name breed and age.

02:07.020 --> 02:16.060
So we could do plenty of other things like location gender is spayed is neutered that sort of thing.

02:16.200 --> 02:18.630
But just doing name breed and age.

02:19.710 --> 02:22.530
So I've put a couple of cats in here.

02:22.650 --> 02:23.540
We've got flu.

02:23.620 --> 02:25.560
Who's this Scottish Fold who's one year old.

02:25.710 --> 02:26.670
That's my cat.

02:26.890 --> 02:30.110
I've got rocket who is a Persian who's three years old.

02:30.240 --> 02:34.200
Totally made up Monte who is a tabby who is 10 years old.

02:34.260 --> 02:36.380
That is my childhood cat.

02:36.450 --> 02:40.050
He's still kicking and biting people.

02:40.080 --> 02:42.720
We've got Sam who is a munchkin.

02:42.720 --> 02:46.470
If you don't know what that breed is look them up they're pretty hilarious.

02:46.470 --> 02:51.940
Although Pender's said they have really stubby legs who is five years old also made that cat.

02:52.200 --> 02:59.280
So some terminology when we're talking about tables and you hear the term columns it's referring to

02:59.280 --> 03:01.230
the headers on that table.

03:01.260 --> 03:06.380
So what are the different components of data the different pieces that have to be there.

03:06.420 --> 03:09.840
In our case we have name breed and age.

03:09.840 --> 03:14.870
So those are the columns and then the rows are the actual data in the table.

03:14.880 --> 03:16.440
So here a row.

03:16.440 --> 03:22.290
Blue Cat is one row rocket is another row Monte is another row Sam.

03:22.350 --> 03:23.430
It's another row.

03:23.430 --> 03:28.480
I really wish those lined up correctly but I just drove myself nuts trying to get it to work.

03:28.560 --> 03:29.940
Please forgive me.

03:29.940 --> 03:34.480
Anyways so databases are made up of lots and lots of these tables.

03:34.500 --> 03:36.380
It's usually not just one.

03:36.630 --> 03:42.640
And if you have a really really simple app and you're just storing one thing then it will just be one

03:42.870 --> 03:47.430
but usually apps are pretty complicated and data is complicated.

03:47.550 --> 03:49.180
All that we modeled there was cat.

03:49.200 --> 03:55.890
But imagine if this was actually an app let's say it was a pet sitting app and cats were one thing that

03:55.890 --> 03:56.890
we had to keep track of.

03:57.000 --> 04:03.720
But we also have to keep track of owners and the pet sitters and addresses and dates and appointments

04:03.750 --> 04:06.630
and payments and those are all going to be tables.

04:06.690 --> 04:09.090
Some of them might even even be multiple tables.

04:09.210 --> 04:12.120
But for now we're not going to really worry too much about that.

04:12.180 --> 04:18.550
But just to show you sometimes it does get crazy you can click this link or I'll click it follow my

04:18.550 --> 04:25.960
own instructions to see the breakdown of some of the tables that Facebook's database or a social network

04:26.470 --> 04:28.570
might use in their database.

04:28.570 --> 04:30.670
So this is not actual.

04:30.780 --> 04:32.310
It's not 100 percent accurate.

04:32.320 --> 04:37.750
There are things that are missing or incomplete but this just shows all the different tables or at least

04:37.750 --> 04:41.170
some of the different tables involved in a pretty complex app.

04:41.170 --> 04:43.700
So as you can see there is a bunch of them here.

04:43.720 --> 04:51.620
Things like accounts and events and message notification Web site screen name address blah blah blah

04:51.640 --> 04:55.100
all these different things to take into consideration.

04:55.210 --> 04:56.640
So things can get messy.

04:56.830 --> 05:02.440
And as you progress in this course you will start working with multiple tables you'll see how they connect.

05:02.440 --> 05:05.070
But we haven't even seen how to create a single table yet.

05:05.110 --> 05:09.170
So we're going to focus just on individual tables and then we'll move on from there.
