All right let's go through the solution.
Spring cleaning or doing our cause inventory and the first step was to create a brand new database called
Schertz the B.
So if we hop over to cloud 9 if we just check what database we're using remember we can do select database
we're using cat app so we're going to make a new database create a database and we want to call it Schertz
underscored TB semi-colon.
Now if we do show databases you can see we have Schertz DBM at the bottom.
All right.
So the next step we need to use Schertz DB Just like that.
And now if we run that same select database line we're currently using.
Sure Stevie.
OK so now this is probably the longest thing you'll have to type.
We need to create a new table we'll call it shirts and it needs to have these five columns shirt ID
which cannot be no and is a primary key which means that we'll have it autoincrement as well.
Article which should be far Chaar.
And let's just for simplicity say all of these have 100 character limit color Vardar 100 shirt size.
Yes we could you kept it short but maybe you might have a shirt size that's small spell that spelled
out the full word rather than just the letter S.
So we're not going to limit that either for now.
And then last worn isn't it.
So let's try it.
We'll do a create table shirts and I'm going to do this on line here.
And the first thing that we have let's start with shirt ID which should be an integer not all auto increment.
Next we're going to move on to article which is a Vardar 100.
And then after that we have color which is also for our char 100.
Then we have shirt size which is also Vardar 100.
And finally we have last worne which isn't just like that and we'll close our parentheses and then we'll
add our semi-colon.
And I forgot something which I did not do on purpose but if you look at the message says incorrect table
definition there can be only one autocall column and it must be defined as a key.
And so I'm missing the primary key definition at the end which this is actually a helpful error.
Often times these error messages aren't that useful but this one tells us exactly what we did wrong.
So I'm going to recall that line and then at the end to add comma primary key then our primary key is
shirt Heidi just like that.
Now if I hit enter and that left off the last print the see again.
So we have another error.
OK.
Now if we hit enter here it worked.
If you'd like to see a nice clean up version what this actually looks like here I have it here.
So create table shirts shirt ID and not know autoincrement article Vardar colored Vardar shirts which
are last worn int primary key shirt ID and the semi-colon and the correct parentheses.
Closing it out.
And that should do it.
All right if we wanted to double check that things worked.
We can do our describe this shirt and you can see we have what we expect.
So the next thing is to get all of this data in our database.
So I gave it to you as this comma separated list where things are all in the same format where we have
you know print the seeds for one shirt and then inside of that we have article first and then color
size.
And then last one so we can insert using that format.
So we'll do an insert into shirts and we have to specify we're doing article first then we're doing
color and we're doing shirt size.
And then finally we're doing last worn and then we need our values.
And I'm just going to hit enter for now and I'm going to paste that giant list.
And we need a semi-colon at the end and we hit Enter good no mistakes this time says records eight eight
rows affected.
OK.
So if we wanted just to double check I can do our select star from shirts and we get the data in there
that we should have.
And then the last thing we need to do is to add a new shirt so manually one shirt rather than bulk inserting
it should be a purple polo shirt that medium.
That was last worn 50 days ago.
So I didn't specify what order you need it to insert into.
So I don't really care.
But do insert into shirts and we'll do color because that's how we specified here color an article then
size and then must warn color article shirt size last worn like that values and it's purple polo shirt
Khama medium Khama 50 just like that OK.
And if we do show like Star we should see that polo shirt down there it's purple medium.
50 days ago we were in.
All right.
So we've now wrapped up the Create part of crud.
We saw how to create the database we inserted created a table we inserted data into the table.
Now we're moving on to reading.