What is SQL & Databases?
Welcome to the world of data! If you’re building software, analyzing metrics, or just trying to keep track of a massive e-commerce store, you need a way to store and retrieve data efficiently. That’s where Databases and SQL come in.
Relational Databases
A Relational Database is a type of database that stores data in structured formats, using rows and columns. Think of it like a highly organized, interconnected collection of spreadsheets.
For the rest of this curriculum, we will be working with a simulated E-Commerce Database. The central components of this database include:
users: The customers shopping on our platform.products: The items we sell.orders: Records of when a user buys something.
Every “spreadsheet” in our database is called a Table.
What is SQL?
SQL stands for Structured Query Language. It is the standard language used to communicate with relational databases. Whether you are using PostgreSQL, MySQL, SQLite, or Oracle, they all speak a dialect of SQL.
With SQL, you can:
- Query: Ask the database for specific information (e.g., “Show me all users from Canada”).
- Manipulate: Add, update, or delete data.
- Define: Create new tables and define the overall structure of the database.
Your First Query
The most fundamental command in SQL is the SELECT statement. It is used to fetch data from a database.
If you want to look at everything inside a table, you use the asterisk (*), which acts as a wildcard meaning “all columns”.
SELECT * FROM users;
This query tells the database: “Retrieve all columns (*) from the table named users.”
[!TIP] SQL keywords (like
SELECTandFROM) are case-insensitive, meaningselectandSELECTboth work. However, capitalizing SQL keywords is a standard convention that makes your code much easier to read! Also, remember to end your queries with a semicolon;.
Time to Practice
On the right side of your screen, you’ll see an interactive terminal connected to our mock E-Commerce database. Your very first task is to write a query that fetches all the data from the users table to see what it looks like. Give it a try!