(upbeat music)
- Once we have a database,
we'll need to actually talk to it.
A common language used to do this is called SQL,
often called SQL,
and it stands for Structured Query Language.
Most relational database management system tools
also called RDBMS tools support ANSI SQL.
That's the version of SQL
defined by the American National Standards Institute,
which is generally considered to be the standard or minimum
most widely supported set of commands for the SQL language.
Though many tools offer their own flavor or version
of the language that extends ANSI SQL
to add features specific to that DBMS.
Two examples of this are T-SQL or Transact-SQL
used by Microsoft SQL Server and MySQL, an open source DBMS
that includes a few other useful features
on top of the SQL standard.
SQL allows us to write statements which the DBMS interprets.
And that's how we interact with data in the database
from apps or even within the DBMS itself.
In this role of interacting with data,
SQL is called a data manipulation language or DML.
SQL also offers features to manage the database itself
by creating and modifying tables
and controlling access to tables.
In these roles, SQL acts as a DDL
or a data definition language,
and a DCL or data control language.
We'll see more about SQL's capabilities as a DDL and DML
in particular later on.
It's likely you'll need to read and write SQL at some point.
So, let's take a few minutes
to explore this foundational language
and we'll get into more details later in the course.
Don't worry about the specifics
of the statements at this point though.
A SQL statement is composed of clauses
which can contain expressions and predicates.
A clause will include a keyword
specifying some action to take
and something to act on or use.
Expressions and predicates set parameters
within which to operate.
Statements can be written inside of software
that works directly with the database
like SQL Server Management Studio or phpMyAdmin,
or they can be incorporated directly into program code
in order to allow an app to access data.
To ask for data from a database,
we'll ask for the fields we want information from
and we'll specify the tables that contain the information.
We might also specify how to display,
sort or associate the information.
And in return we'll get matching records
or the fields from records which match our criteria.
This statement, for example, will show us the first name
and last name of customers with a specific birth date.
And this one would return us a list of customers names
and birth dates sorted chronologically by birthday.
In the first example, we have two clauses.
In the first clause there are field names
and in the second clause there's the name of the table
to read the fields from.
In the second example we have three clauses.
The first ask for the first name, last name
and birthday fields.
The second clause tells the database to use records
from the customers table.
And the third is telling the database which field
we'll use to sort the records we back.
Because we're asking for information from the database
or asking for the database to do something,
these statements are called queries.
In SQL it's common to see the keywords
written in upper case though it's not strictly necessary.
It can help with readability though.
So, in this course I'll keep the keywords uppercased.
Putting data into a database, retrieving information
from a database, changing records and removing records
are typically things we'll do with a SQL query of some sort.
And even if you're working at a higher level
like writing an app that interacts with the database,
eventually whatever you're doing with your data
will get translated into a SQL query
somewhere along the line.
These activities, create, read, update and delete
are called CRUD, and they're the basis
of interacting with data.
SQL allows us to write out what we want
and the DBMS returns what we've asked for
or otherwise acts on the data in the database for us.
(upbeat music)