Brief Introduction to Structured Query Language (SQL)
The lecture introduces you to Structured Query Language (SQL) that is used to interface with a relational database management system (RDBMS).
You learn that information from websites and web applications are ultimately stored in a database, so they persist as you come back to the website at a later time.
You learn that the database can have many tables to store different resources. Each table has columns that are attributes of a specific object. Those objects are presented as rows.
In the example, there is a table of customers. Each row represents a customer. Each column represents a piece of information about that customer. For example, the column first_name stores the customer's first name.
There are many implementations of SQL out there. Many companies have built their own flavor. For example: MySQL, MariaDB, SQLite, PostgreSQL, Microsoft SQL Server, Oracle Database, IBM DB2, etc. But so long as you learn standard SQL, you can easily run queries for any of those specific implementations.
Structured Query Language (SQL) is a vital part of database management.
It is used to store and retrieve information for websites and applications, such as social media platforms.
How SQL Works
User information (like profile details) is stored in a database.
SQL organizes data similar to Excel, using tables with rows and columns:
Columns represent data attributes (e.g., first name).
Rows contain entries for different individuals.
Database Structure
Tables: Represent specific information (e.g., customers, orders, shipping).
ID column: Uniquely identifies each record, typically sequential.
Example:
A table for customers might include columns for first name, last name, age, and country.
Orders table tracks what each customer purchased.
Queries in SQL
Users create queries to retrieve or manipulate data from these tables.
Queries are executed through a SQL editor interface.
Variants of SQL
SQL is a standard language, but various companies have developed their own versions (e.g., MySQL, Microsoft SQL Server, Oracle SQL).
Learning SQL provides a foundation to understand different implementations.
Conclusion
SQL is essential for managing and querying databases, allowing effective data organization and retrieval across various applications.
Video Transcript
So talk about SQL today, structured query language.
Basically, it's database.
When you go today to any website like Facebook,
Instagram, TikTok, whatever you use today,
or even desktop applications,
it's very likely it is using a database to
store all the information that you see.
For example, when you fill your profile,
you have your name, right?
You have some links,
you have your description.
Where does that information go?
Well, ultimately, it goes behind the scenes to a database,
and that's where it is stored so that next time
you access the website, it remembers all of that.
So the most popular way of storing data is via SQL.
It's like a database.
We write in this language called SQL or SQL,
and a structured query language.
So you can think of this as like Excel.
Let me share my Excel.
So it's like except you ever use Microsoft Excel
or Google Sheets or whatever spreadsheet software,
you have rows and columns, right?
So in SQL, basically, we're gonna have what we call tables,
and each table has columns and rows.
So the columns, they denote what kind of information.
For example, I wanna store the first name of somebody.
I can say here first name, right?
So I have a lot of people, I can have John,
I can have Maria, et cetera, right?
So the heading here would be what we call column
for this table.
And then we have each row, right?
The first row is for a specific person.
The second row for another person, and Excel goes on.
So every row represents a different object
or a person in this case.
So when we go back to programies,
what we're gonna see is on the right-hand side,
you see all your available tables for this exercise.
So we have a table of customers,
and as you can see, we have some columns.
And then each row represents a person
or a customer in this case.
So we got information about the first name, last name, age,
and then the person's country.
Now, what we typically do with SQL
is we always have ID column to identify each row.
And it typically is sequential, starting from one,
and then a new one would be two, and so on.
So it's very common, it's a way of uniquely
identify that record.
So we have a table of orders
that's just for orders.
Okay, somebody ordered a keyboard, paid 400 bucks,
and it tells you which customer.
In this case, it goes by ID.
So if you say customer ID four,
it means you gotta go to the customer's table
and see, okay, the person who has ID four
is the one that bought this keyboard.
And then we got shipping.
So this is all about shipping.
You can see shipping of ID one, status still pending,
and the customer is number two.
So number two, okay, I gotta go to the customer's table
and look up who is customer number two,
that's Robert Luna.
So as you can see, each table kind of
represents a specific piece of information.
You cannot have everything together that are not related.
So we separate the customers,
we separate the orders and shippings,
and if you need to find information
across all of those tables, you gotta look them up.
Like they have it here, like, okay, the customer four.
So you gotta always look up in the customer's table
who that is.
Okay, so we got tables and tables have rows
and they have columns.
So in SQL, we make what's called a query
to ask about information.
So in this editor here, you can write a query
and then you can click run SQL
and that will run the query
and do whatever command you wish you did that.
Okay, so today we have different kinds
of flavors of SQL.
SQL is a general term to the structure query language,
but many companies have implemented their own version.
For example, you might have heard of MySQL
or Microsoft SQL Server or Oracle SQL,
so IBM SQL and so on.
Every company kind of make their own version,
but it's all ultimately the same standard language.
If you learn how to write SQL standard,
you will probably, you will understand how to write a query
from any of those flavors.