Jose: Hi Guys, and Welcome back.
In this video we're going to learn more about SQL.
So what is SQL?
How do we use it?
What does it mean?
What's it for?
SQL stands for Structured Query Language,
and it is used to interact with
Relational Database Management Systems.
And those are normally called RDBMS.
And the two terms that we're going to learn in this lecture
Structured Query Language, SQL, or SQL
and
RDBMS.
SQL is meant to be similar to English in some ways.
So the queries or the things that you use it for
sometimes look like English,
or they are meant to be reminiscent of English.
And now, they're not exactly like English
by any stretch of the imagination.
Here we've got for example, a SQL query or Command
used to find some data in a table.
Here we're finding data pertaining to users.
And that's what from users means at the end
and we're selecting the first name and the surname
from each user.
You can see how this is somewhat similar to English.
But obviously, we wouldn't say stuff like this in English.
Now to insert data, for example, as another example,
we're going to learn more about these queries
in a lot of detail as we go through the course.
But just as another example of inserting data
into the users table,
then we specify the columns that we want to insert into,
and the values that we want to insert.
But again, we'll look at that in more detail
as we go along.
Now, at the very top in the first bullet point here,
we mentioned that SQL is used to interact
with Relational Database Management Systems.
So what are Relational databases?
And what are RDBMS?
Well, RDBMS is our large, complex and powerful.
And some examples of them include PostgreSQL,
or MySQL, or even SQL Lite.
SQL lite is, obviously a lite version of an RDBMS.
And it's less powerful,
but it's also much more flexible
in terms of how you can use it.
So we're going to learn more about
what I mean by that as we go along as well.
Databases are primarily constructed from tables,
tables have columns, and they also have rows
and they can have zero rows if the table is empty.
So here we've got an example of a table,
where we've got two columns first name and surname.
And then we've got four rows of data.
John smith, Rolf Smith, Anne Pun and Robert Baratheon.
Some things that may stand out
in here is that you can have duplicate values.
Each row is independent.
So you can have duplicate values in there
like Smith in two rows,
and that's totally fine.
But there are ways to prevent that if you wish,
and we'll learn about those later on.
And you can see that every cell
every row and column combination has a value,
although there are ways to allow empty values
and we will learn more about that later on as well.
All right.
So why Relational?
What does the relational term mean
in the name RDBMS?
Well, it's to do with how tables are used together.
Obviously, for something to be relational,
it has to be related.
So you can see how these two tables here are related
in a way.
You've got the first name and the surname columns there
in the users table, let's call it.
And you've got an accounts table.
And this one has the holder
and the account number of the person.
You can see how they are related because
clearly, John Smith, the first user on the left
is the third user on the right
and it has this account number 9586859.
So there is a relationship between these two tables
and SQL on RDBMS, allow us to formalise
that relationship and make it so that the relationship
is very easily usable.
To simplify relations, we often use unique identifiers
for each row.
So here we're gonna give each row in both tables,
a unique identifier.
Here you can see that, John Smith got the ID one,
Rolf Smith got the idea two, and so on.
Now, that means that we can refer to each user
with just the number because these should be unique.
Similarly, in the accounts table,
we've also gone and given each row an ID,
you can see now that the ID one or the account one
is for Anne Pun, and this is the account number.
However, we've gonna step further
and also give them an ID of the user
that should match this person.
So you can see that the account with ID one
is for user with ID three,
so we can then grab this and go to the users table
and grab a user with ID three, and we get Anne Pun.
Obviously if we do this,
we no longer need the holder column here.
Because the holder ID already allows us
to go to the users table and grab the name.
We don't need to have the name here as well.
So we can just get rid of that.
And this is a very common approach
for designing tables,
you see what pieces of data can be stored in its own table
with its own meaning.
And then you can reference those tables from other places,
we're gonna be doing a lot of this throughout the course.
So don't worry if it's not so obvious at this point in time.
But we're going to be learning a lot more about
how to do this.
So again, through some smart querying of the accounts table,
we could find the user's name.
And similarly through some smart querying
of the users table,
we could for each person find their account number.
So the relationships go both ways,
and we can use them very flexibly.
So let's go and learn about those queries
that we wrote at the start of this presentation.
In the next few videos.
I'll see you in the next one.