WEBVTT

00:00.150 --> 00:00.930
All right.

00:00.930 --> 00:03.000
So if all you care about is the solution.

00:03.030 --> 00:04.130
Just check out the code.

00:04.140 --> 00:08.400
Following this lecture or post the video you can see the solution here.

00:08.640 --> 00:12.300
But I'll go ahead and go through the process of typing this out very quickly.

00:12.300 --> 00:14.320
I'll kind of speed it up.

00:14.390 --> 00:20.230
So what I'd like to do is start by defining the rough skeleton of what we need in a sequel file.

00:20.430 --> 00:32.680
So we need a create table employees and then within that we'll have Id have first name last name of

00:33.000 --> 00:39.100
middle name and then we have age and current status just like that.

00:39.420 --> 00:41.100
And then we can fill in the data types.

00:41.220 --> 00:47.180
So we know ID is an integer and age is an integer then these are our chars for our cars.

00:47.370 --> 00:49.500
Let's say 2 5 5.

00:50.180 --> 00:56.660
So somebody may have a giant name and same for current status.

00:56.660 --> 01:03.980
So then the next thing that we could do is focus on an idea which we know needs to autoincrement And

01:03.980 --> 01:07.940
we also want it to be mandatory and a primary key.

01:07.940 --> 01:09.940
So mandatory means not know.

01:10.320 --> 01:13.130
And the primary key there's actually two options.

01:13.190 --> 01:18.970
The first one is to do this and the second one just duplicate this.

01:19.020 --> 01:23.880
It's also in the slides is to add it on the end here.

01:25.350 --> 01:28.130
We don't want that underscore that.

01:28.200 --> 01:29.020
There we go.

01:29.460 --> 01:31.300
So these will do the same thing.

01:31.380 --> 01:33.000
But of course we're not done.

01:33.000 --> 01:38.940
So the next thing would be first name and first name it's just mandatory as is last name.

01:38.940 --> 01:43.270
So we'll just add not no and not no middle name.

01:43.290 --> 01:50.510
We can leave alone and we've got age which is also mandatory.

01:50.630 --> 01:55.340
And then finally current status which is mandatory but there's also a default value.

01:55.550 --> 02:05.610
So we want nominal defaults employed and then we need to make sure we have all the correct Comus here.

02:08.050 --> 02:12.400
Just like that at our semi-colon aswell.

02:12.670 --> 02:14.130
Copy it.

02:14.240 --> 02:15.970
Let's see what happens.

02:15.970 --> 02:16.350
All right.

02:16.360 --> 02:25.390
So looks good we can describe employees and then if we wanted to let's just do a single test insert

02:25.390 --> 02:28.540
to make sure our default value works in our autoincrement works.

02:28.540 --> 02:38.350
So what do you insert into employees and we'll do it first name a last name com age and that's it.

02:38.350 --> 02:45.630
Because everything else either has and is allowed to be know or has a default value and will insert

02:45.640 --> 02:50.440
someone with the name of Dora Smith.

02:50.500 --> 02:51.420
Yes.

02:51.580 --> 02:54.880
And let's say she is fifty eight.

02:55.390 --> 02:56.510
OK.

02:57.070 --> 02:58.460
Copy that set in.

02:58.790 --> 03:06.700
Let's do a select star from employees just like that and it looks good.

03:06.700 --> 03:10.600
We've got an I.D. auto incrementing at one first name last name.

03:10.660 --> 03:12.010
Middle name is No.

03:12.010 --> 03:17.620
Because it's allowed to be age of 58 and current status is employed because we didn't specify one.

03:17.620 --> 03:19.990
And we have a default value.

03:19.990 --> 03:20.760
All right.

03:20.830 --> 03:27.610
So again the other solution here is just to put primary key on the same line when you're defining the

03:27.700 --> 03:28.250
column.

03:28.270 --> 03:29.430
I prefer to do it that way.

03:29.440 --> 03:32.380
But you also see it done this way both work.

03:32.650 --> 03:33.080
All right.

03:33.130 --> 03:33.680
That's it.
