All right.
I mentioned I wanted to get us to writing some code as soon as possible.
So that's what we're going to do in this video.
Obviously, it's super early on in the course, so don't get your hopes up for doing anything crazy.
Impressive.
It's going to be pretty basic.
But the idea is that I just want to introduce you to writing some SQL, show you what it's like.
So the first thing you'll need to do is click on this link if you want to open the slides.
I've included them with this lecture or I've included the link itself as a resource with this lecture.
So however you would like to get there, go to this link which takes us to this page right here.
This is the Try SQL editor and I'm going to make my screen a little bit bigger just so that you can
see it.
Here we go.
And I'll start by just deleting what's already in there.
So you might be wondering what is this place?
That's a good question.
It's an interactive, browser based SQL environment.
And what that really means is that think of it as your own personal SQL sandbox in the browser, where
you can go try some things out and play around.
It's purely for educational purposes.
So this is not what you would be doing if you were actually working with a real production database.
But what it lets you do is type some SQL queries and run them by clicking this run SQL button and you'll
get a result.
And that's fundamentally the process of working with SQL.
You type something and then you run it and then you get something back.
Oh, and before we go any further, I should point out that we're talking about SQL here, not my SQL
yet.
And if you're confused about that distinction, totally normal question to have, wait until the next
section when I go into detail about the differences.
But for now, I'd like you to try running some code.
So here's the first line of SQL that we can try running select star from customers.
So you can either type this or copy it from the slides or from the included code file after this lecture.
So I'll just copy it from the slides here.
And then back in the editor, I'll paste it in and click Run.
So the first thing you'll notice is that we get a bunch of data back.
So I'm not going to go into the details of the syntax and what all of this means for every command we
run.
It's really more about just giving you an experience of running commands.
The rest of the course talks about the details and the syntax, but what this does is it gives us all
of the data about customers in this database.
So you can see we've got 91 customers and every customer here has a name.
So these are stores or restaurants.
There's the contact at the restaurant or at the business, the address, the city, the postal code
and the country.
So that's all I'll say about that select start from customers.
That gives us all of our customers data that are in the database right now.
So here's another thing we could try.
It's very similar select star from orders.
So we'll just copy that and back here and the editor, I'll paste it in and click Run SQL, Run SQL.
Same thing happens, but this time we get all of our data printed out for our orders.
So you might be wondering where is this data coming from in the first place?
Very good question.
It's preprogrammed in here.
So every time you open this in your browser, you have this pre loaded data set that you can work with.
And just by taking a quick look at our order data, you can see we have things that can order ID, a
customer ID, an employee ID and order date and a shipper ID, but there's really not much descriptive
information here, and that's actually why I chose this table.
I wanted to make the point that a lot of the data you'll be working with on its own, or like a snapshot
like this, isn't very meaningful.
What we actually want to do is start combining it with other tables.
So we're not going to do that now, but that's what we're building up towards the end of the course
is how do I combine customers with orders and products and shippers to get some meaningful answers out
of my data?
So here's another thing we can do very similar to what we've done already, but there's a little bit
extra.
So select start from products order by price descending DSC and if I paste that in here and click Run,
what I get now are all of the products in my database.
So they have a product ID, a name, a supplier ID, category ID, a unit and then a price.
And they're currently sorted by most expensive down to the cheapest all the way at the end.
So I won't force you to listen to me trying to pronounce some of these, but these are our products
and they're currently sorted by price.
So just a simple modification to the query yields radically different results.
And if we just get rid of that order by price, we get the same data back.
But now it's ordered by product ID rather than the price.
And stepping up in complexity a little bit here, here's another query.
This one significantly longer, and this one actually involves two different entities.
So we saw customers, we saw orders separately.
If you try copying this and pasting it in and you click run, what we actually get here is a list of
records for a customer and then the number of orders a given customer has placed.
So remember, this data is stored in two separate places.
We had the customer's data that had nothing to do with orders, and then we had the orders data and
all that it contained was customer ID and then we've combined them with this query.
So do not focus on the syntax.
Don't panic about that.
Of course we'll get there.
We'll talk a lot more about how to structure queries.
I mean, most of this course is about structuring complex queries.
In fact, here's a quick preview of some of the things we'll be doing.
So here's an example of a slightly more complicated query.
This time we're working with photos and images.
We're working with users and likes and putting them all together to get some information out.
And here's another one a little bit crazier where we're working with ratings or reviews and TV shows
and reviewers.
So think of like a Netflix or iTunes where you could rent or watch a TV show and then rate it from 1
to 10 or 0 to 5 or whatever the rating scale is here.
We're working with that data to figure out who our power users are, who are the most active users,
who are reviewing the most things.
So we'll be building up to these sort of queries, and by the end of the course you should be able to
make sense of this and do a lot more, by the way.
So that was a taste of SQL.
Hopefully it didn't taste too bad.
So in the next section we'll dive into the nitty gritty of what SQL is and how it compares to my SQL.
We'll get everything installed, and then finally we'll have our first set of exercises.