Use Sophia to knock out your gen-ed requirements quickly and affordably. Learn more
×

Databases and SQL Fundamentals

Author: Sophia

what's covered
In this lesson, you will explore the foundational logic and problem-solving strategies that power computer programming. You will not need to install coding tools or use an IDE; instead, you’ll work with code snippets, logic flow, and debugging examples to learn how programmers think and work.

Specifically, this lesson will cover the following:

Table of Contents

1. Why Database Skills Matter

Every day, companies around the world collect massive amounts of data, such as customer interactions, sales transactions, and social media activity. This immense collection is commonly referred to as big data. However, despite the vast amounts of information businesses accumulate, research suggests that organizations typically analyze only about 1% of their data effectively. The remaining 99% remains unused, not because it isn’t valuable but because companies often lack the skills or tools to efficiently explore and retrieve actionable insights.

That’s where database skills, especially SQL (Structured Query Language), become crucial. SQL allows IT professionals to directly and efficiently retrieve precisely the information they need, turning overwhelming quantities of data into valuable, actionable insights.

did you know
The New York Stock Exchange generates about one terabyte of data every day just from trading activity. That’s roughly the equivalent of 500 hr of HD video. Without tools such as SQL to organize and search through it, most of that information would be impossible to use.

In this lesson, you’ll begin developing the foundational SQL skills necessary to overcome the 1% challenge. You’ll practice applying basic SQL commands to extract useful information from databases, allowing you to understand how businesses are transforming data into opportunities for informed decision-making.


2. Database Fundamentals

Before you can start writing SQL queries, it’s important to understand how data is organized inside a database.

A database is a structured system for storing information. Think of it like a digital filing cabinet that holds large amounts of data in a way that makes it easy to find specific details when needed. Inside a database, information is stored in tables. These tables look similar to spreadsheets, with rows and columns.

Each row in a table represents one individual item, such as a customer, an order, or an employee. Each column contains a specific type of information, such as a name, date, or location. For example, a table called “Employees” might include columns for name, department, and salary, and each row would show the details for one person.

To find specific information in a database, professionals use a special tool called SQL, which stands for Structured Query Language. SQL is the language used to talk to databases. It lets you search, filter, and organize data using short, clear commands.

Instead of scrolling through thousands of rows manually, you can write a simple SQL command to pull out just the data you need. For example, you could use SQL to find all the customers who made a purchase last week or to list the employees in a certain department.

In the next section, you’ll start learning how to write these kinds of commands yourself. For now, just remember this: databases store information in tables, and SQL is how we ask questions about that information to get useful answers.

terms to know
Database
A structured collection of data that stores information in an organized way so that it can be easily accessed, managed, and updated.
Table
A part of a database that holds data in rows and columns, like a spreadsheet. Each table focuses on one type of information, such as customers or products.
Row
A single entry in a table that represents one item or person.
Column
A specific type of information in a table.
Structured Query Language (SQL)
A programming language used to communicate with databases and retrieve, update, or manage the data they contain.


3. Basic SQL Commands and Query Structure

Now that you know how databases store information in tables made up of rows and columns, you’re ready to start learning how to work with that data. To do that, you will use SQL, the language designed to ask clear, specific questions and return exactly the information you need.

3a. The SELECT Statement

The most common SQL command is SELECT. It tells the database what information you want to retrieve.


SELECT column_name FROM table_name;

This command means “Show me the values in this column from this table.”

EXAMPLE

Let’s say we have a table called Employees with the following data:

Name Department Salary
Rosa IT 65,000
Malik Sales 55,000
Jenna Marketing 60,000

Let’s look at this SQL command:


SELECT Name FROM Employees;

This comand asks the database to return the Name column from the Employees table. The result would be:

Rosa
Malik
Jenna

Given the following SQL command:


SELECT Department FROM Employees;

In the next section, you’ll learn how to filter results using WHERE to narrow down your search. This lets you be more specific about the data you want to see.

3b. The WHERE Statement

Sometimes, you don’t want to see all the data in a table. You might only want to see employees in the Sales department or products that cost more than $50. That’s where the WHERE clause comes in.

The WHERE command lets you filter the results of your query by setting a condition. It helps you focus on just the rows that match what you’re looking for.

SQL Structure


SELECT column_name FROM table_name WHERE condition;

This command means that you want to be shown this column from this table, but only if the data meets this condition.

EXAMPLE

Let’s use the same Employees table:

Name Department Salary
Rosa IT 65,000
Malik Sales 55,000
Jenna Marketing 60,000

Let’s say you want to see only employees who work in the Sales department.


SELECT Name FROM Employees WHERE Department ="Sales";

This query returns the following:

Malik

The WHERE clause told SQL to ignore any rows where the Department was not “Sales.”


SELECT Name FROM Employees WHERE Salary > 58000;

As your ability to ask questions with SQL grows, you’ll start to work with more specific conditions. That’s when you’ll need to combine filters to narrow or expand your results, and that’s exactly what you’ll do next.

3c. AND and OR Operators

So far, you’ve used WHERE to filter results based on a single condition. But most questions involve more than one. You might want to find employees who work in Sales and earn more than $50,000, or customers who live in New York or Chicago. To write queries like these, you’ll use two new helpful keywords. These keywords let you combine two or more conditions in a single query, giving you more control over what data is returned.

The keyword AND lets the database know that both conditions must be true for a row to be included in the results.

For example, imagine this table:

Name Department Salary
Rosa IT 65,000
Malik Sales 55,000
Jenna Marketing 60,000
Brian Sales 49,000

If you want to find employees who are in Sales and have a salary greater than 50,000, you would write as follows:


SELECT Name FROM Employees  
WHERE Department = "Sales" AND Salary > 50000;

The database checks each row. Only Malik meets both conditions. Brian works in Sales, but his salary is too low. Everyone else is in a different department.

When you use OR, you’re saying that either condition can be true. If one matches, that’s enough.

Here’s an example:


SELECT Name FROM Employees  
WHERE Department = "Sales" OR Department = "Marketing";

This query returns any employee who is in Sales or Marketing. That includes Malik, Jenna, and Brian.

Even though Brian’s salary is under 50,000, he’s still in Sales, so he qualifies. Jenna is in Marketing, so she qualifies too.


SELECT Product FROM Products  
WHERE Category "Electronics" AND Price > 500;

SELECT Product FROM Products  
WHERE Category "Furniture" OR Price < 500;

SELECT Title FROM Books
WHERE Price > 20 AND Author "Kim Lang";
try it
Imagine you have the following Products table:

Product Category Price
Laptop Electronics 900
Chair Furniture 120
Phone Electronics 600
Desk Furniture 300
Tablet Electronics 400


Question 1
Which products match?
Laptop
Phone
Question 2
Which products match?
Chair
Desk
Tablet


4. How an SQL Query Answers a Real Question

To really understand the impact of SQL and how it is used, it is helpful to understand how each part of a query works to answer a specific question. Even if you’re not writing full SQL statements yet, seeing how they’re structured can build your confidence and help you recognize what different commands are doing. The following example shows how SQL helps professionals pull useful information from a database, one clear step at a time.

EXAMPLE

Let’s say you work in an online bookstore and want to find out which books cost more than $20 and were written by Kim Lang. Instead of scrolling through every product manually, you can use an SQL query to pull exactly what you need from the database.

Here’s the SQL query that would answer that question:

Even if you’re not writing full SQL statements yet, seeing how they’re structured can help you build confidence and recognize what each part is doing. The following example walks through the logic step by step.

What the Query Is Doing

  • SELECT Title tells the database to show only the values in the Title column.
  • FROM Books tells SQL which table to search. The table is named “Books.”
  • WHERE Price > 20 filters the results to include only books that cost more than $20.
  • AND Author = "Kim Lang" adds another condition: The book must also be written by Kim Lang.
Together, the query finds all books that meet both conditions: They must cost more than $20 and be written by Kim Lang.

The Books Table

Title Author Price
Code Breakers Kim Lang 18.99
Debugging Life Marcus Trent 22.50
SQL for Starters Riley Chen 25.00
Data Dive Aisha Grant 19.95
Advanced SQL Kim Lang 24.99

What the Query Returns

Advanced SQL

This simple query answers a clear business question using just one line of code. It would work the same way even if your database contained thousands of rows.

If you enjoyed using logic to ask questions and retrieve specific information from a table, you are already thinking like a data professional. Skills such as writing SQL queries are used in many IT careers, including data analysis, software development, business intelligence, and cybersecurity. If this work sparked your interest, consider taking a course such as Intro to SQL or Intro to Databases. These classes expand on what you’ve learned here and can help you build the skills to manage and explore real-world data.


If you found it interesting to break down tasks into step-by-step logic or enjoyed spotting and fixing errors, you are already thinking like a programmer. Skills like writing pseudocode and debugging are not just for coding; they are essential in many IT careers, including software development, data analysis, cybersecurity, and DevOps. If this kind of thinking appeals to you, consider taking an introductory programming course such as Intro to Python or Intro to Java. These classes build directly on what you have practiced here and can help you take the next step toward a technical career path.

summary
In this lesson, in why database skills matter, you saw that data is everywhere, and without the right tools, most of it just sits unused. SQL changes that by helping you pull out exactly the details you need. As you looked at understanding databases, you pictured a database like a digital filing cabinet, with tables, rows, and columns keeping everything organized so that SQL can quickly find what you are looking for. SQL commands allowed working with the data to ask more specific questions, even allowing the application of SQL in action, to walk through a real example to answer a business question in seconds, the same way IT professionals do every day.

Source: THIS TUTORIAL WAS AUTHORED BY SOPHIA LEARNING. PLEASE SEE OUR TERMS OF USE.

Terms to Know
Column

A specific type of information in a table.

Database

A structured collection of data that stores information in an organized way so that it can be easily accessed, managed, and updated.

Row

A single entry in a table that represents one item or person.

Structured Query Language (SQL)

A programming language used to communicate with databases and retrieve, update, or manage the data they contain.

Table

A part of a database that holds data in rows and columns, like a spreadsheet. Each table focuses on one type of information, such as customers or products.