So now that we've seen how to use source, we're going to take advantage of it to get some sample data
going for the next couple of videos and exercises.
Cats are kind of boring.
They're pretty simple at this point.
Name and age and breed, and we need some more complicated data and that's a little something that's
a little more real world.
So we're still not working with something straight out of a production app because we haven't seen some
of the features that we need to know for that to work.
So it's still kind of simplified data, but what we're working with is books data.
So this is what we have.
I've given you this file so you can find it in the file section or of the downloadable section of this
video.
Basically, there's two parts for creating a books table, and I'll go over that in just a second.
And then after that table is created, there's a bunch of values that I'd like for you to insert, and
I didn't want you to have to type these all at once, but I want us to all have the same data as we
can be on the same page when we run exercises.
So all of this data is actually real data.
It's about books from Amazon.
And basically it has every book has a book ID, so that should not be new.
There's a title, it's a bar chart.
Then we have an author, first name and an author last name.
So if we look at one, Here's The Namesake.
That's a title.
The author first name is Jhumpa, and her last name is Lahiri.
Then we have the released year.
So what year was it released in?
And this is an example where we're using kind of the I don't want to say dumbed down but simplified
version of data, because typically you would probably store a date, an actual date, not just a number
like 2003.
So we'll see how to do that once we talk about dates.
But for now, we just have 2003 and then the next thing is stock quantity and this is just an arbitrary
number I picked.
The idea here is that we have a fictional bookshop and we're keeping track of all the books and how
many we have in stock.
So for The Namesake, we have 32 copies in stock.
For a hologram for the king.
We have 154 copies in stock.
Then the final thing is the pages.
How many pages are in that book?
So you can see some books are really long, like The Amazing Adventures of Kavalier and Clay at 634
pages.
And some are much shorter, like what we Talk About When We Talk About Love by Raymond Carver.
Really good short stories, if you like.
Short stories, 176 pages.
So a note about these books.
I started off by just picking off the best sellers on Amazon as of writing today.
So I think that's where this one Norse mythology by Neil Gaiman came from.
But I then just decided to create a variety of ears and page numbers, some of my favorite authors.
It's a whole mix of things.
So it is real world in a sense, but it's also sort of I planned certain things to work certain ways.
So we have certain we have some really long titles and some short titles.
We have some really long books and short books.
We have some books from the 2000 and some from the 1900s and so on.
Basically, I wanted a variety of things that we could practice with.
So go ahead, create a file in cloud nine and put all of this in there.
Now, if you want to type it, go ahead.
But I would recommend that you don't just so that you don't accidentally mess something up.
We want our data to be consistent.
So go ahead, copy it.
Make a new file, and then we need to execute that file.
And I want to make a new database right now.
If we do select database, we're working with Cat app.
I want to create database and we'll call it bookshop and then use bookshop and we should have a blank
slate if we do show tables.
There should be nothing here.
Perfect.
So what you want to do is make sure this file has been saved and then we just execute it.
So it's pretty straightforward source and then you'll need to make sure you either are referencing the
correct path.
So in my case, I'm running my CLI in my root directory.
So all I have to do is book data, SQL.
Whatever you called it, you'll need to refer to.
I recommend just putting it in the main directory for now.
But we could you could have a separate folder if you wanted to and you just need to refer to it correctly
anyways.
Source book data dot SQL.
And here we go.
All right.
First thing, we get this message and that tells us they create table worked and then we get 16 rows
affected.
And that tells us the insert statement worked.
So let's just verify.
Let's do it.
Describe books.
Here we go.
Here's all that we created in that table, and let's just do a simple select star from books.
As you can see, it's pretty messy.
And that's still a.
We're going to work on ways.
We're going to see ways of refining this and making things shorter, collapsing data and so on.
So that's all we're doing in this video.
We're just getting set up.
Now that we have it in there in our database, we'll be able to work with it and be on the same page.
Awesome.