Skip to content

You will practice using SQL to communicate with databases. You’ll learn how to query a database and filter the results. You’ll also learn how SQL can join multiple tables together in a query.

Learning Objectives

  • Discuss how SQL is used within the security profession.
  • Describe how a relational database is organized.
  • Use SQL to retrieve information from a database.
  • Apply filters to SQL queries.
  • Use SQL joins to combine multiple tables into a query.

Introduction to SQL and Databases


Video: Welcome to module 4

  • Diversity of perspectives and tools is crucial in the field of security.
  • SQL is a powerful and flexible tool that allows security analysts to analyze data effectively.
  • The course will cover relational databases, SQL queries, SQL filters, and SQL joins.
  • Hands-on experience will be provided to gain proficiency in using SQL.

In the world of security,
diversity is important. Diverse perspectives are often needed to find
effective solutions. This is also true of
the tools we use. Your job will often require you to use a lot
of diverse tools. In the last section, we studied the Linux command
line and learned how this tool can help you search
and filter through data, navigate through the
Linux file system, and authenticate users. Now, we’ll learn
about another tool. In this section, we’ll
explore SQL and how it allows you to analyze data in a way needed for your role
as a security analyst. We’re going to start
off by learning about relational databases and
how they’re structured. From there, we’re
going to introduce SQL queries and how to use them to access data
from databases. We then move on to SQL filters, which help us refine our queries to get the exact
information we need. Lastly, we’ll explore SQL joins, which allow you to
combine tables together. When I’m presented with a
problem or a project at work, I often have to sift through
a large amount of data. When I use SQL, I’m able to review data quickly
and provide results with confidence since the queries are consistent and easily executed. SQL is a very powerful
and flexible tool. Throughout this section, you’ll learn how to use
the parts of it you need as a security analyst
and gain hands-on experience. Good luck, and I’ll join you
for the rest of the course!

Video: Introduction to databases

  • Our modern world is data-driven, and databases are essential for storing and managing large amounts of data.
  • Databases are organized collections of information, similar to spreadsheets, but they can handle more data and support multiple users simultaneously.
  • Relational databases are a common type of database that stores data in tables with rows and columns.
  • Each table contains fields of information, also called columns, which represent different attributes of the data.
  • Rows, also called records, contain specific data related to the columns in the table.
  • Relational databases can have multiple tables connected through common columns called keys.
  • The primary key is a unique identifier for each row in a table, while the foreign key connects two tables by referencing the primary key of another table.
  • SQL is the language used to interact with databases, and we will gain hands-on experience working with it throughout this section.

Our modern world is filled with data and that data almost always guides us
in making important decisions. When working with large amounts of data,
we need to know how to store it, so it’s organized and
quick to access and process. The solution to this is through databases,
and that’s what we’re exploring in this video! To start us off, we can define a database as an organized
collection of information or data. Databases are often
compared to spreadsheets. Some of you may have used Google Sheets or another common spreadsheet
program in the past. While these programs are convenient
ways to store data, spreadsheets are often designed for a single user or
a small team to store less data. In contrast, databases can be accessed
by multiple people simultaneously and can store massive amounts of data. Databases can also perform complex
tasks while accessing data. As a security analyst, you’ll often need to access databases
containing useful information. For example, these could be databases
containing information on login attempts, software and updates, or
machines and their owners. Now that we know how important
databases are for us, let’s talk about how they’re organized and
how we can interact with them. Using databases allow us to store large
amounts of data while keeping it quick and easy to access. There are lots of different ways we can
structure a database, but in this course, we’ll be working with
relational databases. A relational database is a structured
database containing tables that are related to each other. Let’s learn more about what
makes a relational database. We’ll start by examining
an individual table in a larger database of
organizational information. Each table contains fields of information. For example, in this table on employees, these would include fields like
employee_id, device_id, and username. These are the columns of the tables. In addition,
tables contain rows also called records. Rows are filled with specific data
related to the columns in the table. For example, our first row is a record for
an employee whose id is 1,000 and who works in the marketing department. Relational databases often
have multiple tables. Consider an example where we have two
tables from a larger database, one with employees of the company and another
with machines given to those employees. We can connect two tables if
they share a common column. In this example, we establish a relationship between
them with a common employee_id column. The columns that relate two tables
to each other are called keys. There are two types of keys. The first is called a primary key. The primary key refers to a column
where every row has a unique entry. The primary key must not have any
duplicate values, or any null or empty values. The primary key allows us to uniquely
identify every row in our table. For the table of employees,
employee_id is a primary key. Every employee_id is unique and there
are no employee_ids that are duplicate or empty. The second type of key is a foreign key. The foreign key is a column in a table
that is a primary key in another table. Foreign keys, unlike primary keys,
can have empty values and duplicates. The foreign key allows us to
connect two tables together. In our example, we can look at the
employee_id column in the machines table. We previously identified this as
a primary key in the employees table, so we can use this to connect every machine
to their corresponding employee. It’s also important to know that a table
can only have one primary key, but multiple foreign keys. With this information, we’re ready
to move on to the basics of SQL, the language that lets
us work with databases. Throughout this section, we’ll gain hands-on experience working
with the concepts we just covered!

Video: Query databases with SQL

  • SQL is an essential tool for security analysts as it allows them to interact with and retrieve information from databases.
  • SQL queries are used to request specific data from database tables.
  • SQL can be used to retrieve logs, which are records of events that occur within an organization’s systems.
  • Security logs are often very large and difficult to process manually, but SQL can be used to quickly extract relevant rows of data.
  • SQL can also be used for basic data analytics, which is another valuable skill for security analysts.
  • In the next video, we will learn how to make basic SQL queries to a sample database.

As a security analyst, you’ll need to
be familiar both with databases and the tools used to access them. Now that we know the basics of databases, let’s focus on an important tool
used to work with them, SQL, and learn more about how analysts
like yourself might utilize it. SQL, or as it’s also pronounced, S-Q-L,
stands for Structured Query Language. SQL is a programming language used
to create, interact with, and request information from a database. Before learning more about SQL,
we need to define what query means. A query is a request for data from a
database table or a combination of tables. Nearly all relational databases rely
on some version of SQL to query data. The different versions of SQL only have
slight differences in their structure, like where to place quotation marks. Whatever variety of SQL you use, you’ll find it to be a very important
tool in your work as a security analyst. First, let’s discuss how SQL
can help you retrieve logs. A log is a record of events that occur
within an organization’s systems. As a security analyst, you might be tasked
with reviewing logs for various reasons. For example, some logs might contain
details on machines used in a company, and as an analyst, you would need to find those machines
that weren’t configured properly. Other logs might describe the visitors
to your website or web app and the tasks they perform. In that case, you might be looking for unusual patterns
that may point to malicious activity. Security logs are often very large and
hard to process. There are millions of data points, and it’s very time consuming
to find what you need. But this is where SQL comes in! It can
search through millions of data points to extract relevant rows of data using
one query that takes seconds to run. That’s pretty useful, right? SQL is also a very common language
used for basic data analytics, another set of skills that will set
you apart as a security analyst. As a security analyst, you can use
SQL’s filtering to find data to support security-related decisions and
analyze when things may go wrong. For instance, you can identify what machines
haven’t received the latest patch. This is important because patches are
updates that help secure against attacks. As another example,
you can use SQL to determine the best time to update a machine based
on when it’s least used. Now that we know why
SQL is important to us, we’re going to start making basic
queries to a sample database! This is definitely exciting, and
I’ll meet you in the next video.

How do security analysts commonly use SQL in their work?

To find relevant information to support cybersecurity-related decisions

Security analysts commonly use SQL to find relevant information to support cybersecurity-related decisions.

Reading: SQL filtering versus Linux filtering

Reading

Video: Adedayo: SQL in cybersecurity

Sure, here is a summary of the text:

Adedayo is a Security Engineer at Google who believes that anyone can learn cybersecurity, regardless of their background. He shares his own experience learning SQL, a crucial skill for cybersecurity professionals. Adedayo recommends taking online courses and practicing regularly to improve your SQL skills. He emphasizes the importance of data-driven decision-making in cybersecurity and the fulfillment that comes from working on impactful projects.

My name is Adedayo, and I’m a Security
Engineer at Google. A lot of people think you
need to have a degree in computer science, right
to be able to get into cybersecurity. I
don’t think that’s true. Take me for an example, I started learning
IT from Lagos, Nigeria where I was
born and raised, and then I’m all
the way here now in Silicon Valley,
working for Google. I think that’s just amazing
and a dream come true. You taking this certificate
is a first step to you making a commitment to switching your career to cybersecurity.
Kudos to you on that. SQL is one of the skillset you need to
have in your toolbox as a cybersecurity professional
because you can very quickly make decisions, not just off the bat, but make decisions
with data backing you, and be able to communicate
with your team, with stakeholders
about why you made a decision because it’s one
thing to be able to say, we need to do this, it’s another thing to say
we need to do this and here’s the data that I
wrote my SQL statements about. I learned SQL by, first, as a coursework in school,
that was really great, but I think I forgot everything
about that after school. The next step that I took
was taking online courses, such as the one you’re
taking right now to learn SQL and the fundamentals about it and how
to really use it. Then the first time I used SQL
practically was at Google. You really need to practice. I think with anything else,
practice makes perfect. Being able to, even if it’s
just a few hours a week, put aside time to practice
writing SQL statement. Having that skill is
something that will be very applicable
to your first job, and you can use that to
make data-driven decisions. I feel very fulfilled
working in cybersecurity. I feel very energized, come into work every day. Not only because
I get to work on really complex problems and try to figure out
solutions for them, but I also have great
teammates that we all come together and
tackle the problem. Being able to go
to bed at night, knowing that the work that
I do is for the better of Google users and
Google employees is a very rewarding
feeling for me.

Practice Quiz: Test your knowledge: SQL and databases

Which statement accurately describes the organization of a relational database?

What is SQL used for? Select two answers.

A record of attempts to connect to an organization’s network is one example of a log. 

Fill in the blank: A request for data from a database table or a combination of tables is called a _____.

SQL queries


Video: Basic queries

This video explains how to run a basic SQL query to determine which computer has been assigned to a certain employee. The query uses the SELECT and FROM keywords to specify which columns to return and which table to query. The syntax of SQL is similar to everyday language, and keywords are not case-sensitive. Semicolons are placed at the end of the statement. To return all columns from a table, use an asterisk after SELECT. Congratulations on completing your first basic query in SQL!

In this video, we’re going to be running our very
first SQL query! This query will be based on a common work task
that you might encounter as a security analyst. We’re going to determine which computer has been
assigned to a certain employee. Let’s say we have access
to the employees table. The employees table
has five columns. Two of them, employee_id
and device_id, contain the
information that we need. We’ll write a query
to this table that returns only those two
columns from the table. The two SQL keywords we need for basic SQL queries
are SELECT and FROM. SELECT indicates which
columns to return. FROM indicates which
table to query. The use of these keywords
in SQL is very similar to how we would use these
words in everyday language. For example, we can
ask a friend to select apples and bananas from the big box when going
out to buy fruit. This is already very
similar to SQL. So let’s go ahead and use
SELECT and FROM in SQL to return the information
we need on employees and the
computers they use. We start off by typing
in the SQL statement. After FROM, we’ve identified that the information will be pulled from the employees table. And after SELECT, employee_id
and device_id indicate the two columns we want to return from this table. Notice how a comma separates the two columns that
we want to return. It’s also worth
mentioning a couple of key aspects related to
the syntax of SQL here. Syntax refers to the
rules that determine what is correctly structured
in a computing language. In SQL, keywords are
not case-sensitive, so you could also write select
and from in lowercase, but we’re placing them in
capital letters because it makes the query
easier to understand. Another aspect of this syntax is that semicolons are placed at the end
of the statement. And now, we’ll run the query
by pressing Enter. The output gives us
the information we need to match employees
to their computers. We just ran our very
first SQL query! Suppose you wanted to know what department
the employee using the computer is from, or their username, or the
office they work in. To do that, we can
use SQL to make another statement
that prints out all of the columns
from the table. We can do this by placing
an asterisk after SELECT. This is commonly referred
to as select all. Now, let’s run this query to
the employees table in SQL. And now we have the full
table in the output. You just made it
through a basic query in SQL, congratulations! In the next video, we’ll learn how
to add filters to our queries, so I’ll
meet you there!

Which columns will SELECT * return?

All columns from the specified table

SELECT * instructs SQL to return all columns from the specified table.

Reading: Query a database

Reading

Video: Basic filters on SQL queries

Filtering is a powerful feature of SQL that allows you to select specific pieces of data from a database. This is done by adding a WHERE clause to your SELECT statement. The WHERE clause specifies the condition for the filter, which can be based on an exact value or a pattern. For example, you could filter a log-in attempts table to find all attempts from a specific country or all offices in the East building.

There are two main types of operators used in SQL filters: the equal to operator (=) and the LIKE operator. The equal to operator returns records that are equal to a particular value, while the LIKE operator returns records that match a pattern. For example, the following query would return all records in the log-in attempts table where the country column is equal to ‘USA’:

SQL

SELECT * FROM log_in_attempts WHERE country = 'USA';

The following query would return all records in the employees table where the office column starts with the word ‘East’:

SQL

SELECT * FROM employees WHERE office LIKE 'East%';

By using filters, you can make your SQL queries more selective and get the exact data you need.

Introduction to SQL Filters

SQL, or Structured Query Language, is a powerful tool for interacting with databases and retrieving specific data. Filtering is a fundamental aspect of SQL queries, allowing you to narrow down the results based on specific criteria. By applying filters, you can ensure that your queries return only the data that is relevant to your analysis or task.

Understanding the WHERE Clause

The WHERE clause is the primary tool for applying filters in SQL queries. It specifies the conditions that must be met for a record to be included in the query’s results. The syntax of the WHERE clause is straightforward:

SQL

SELECT * FROM table_name WHERE condition;

In this syntax, table_name represents the table from which you want to retrieve data, and condition is the expression that defines the filtering criteria.

Common Filter Operators

SQL provides a variety of operators for constructing filtering conditions. Here are some of the most commonly used operators:

  • Equality (==): Checks if a column value is equal to a specified value.
  • Inequality (!=): Checks if a column value is not equal to a specified value.
  • Greater than (>): Checks if a column value is greater than a specified value.
  • Less than (<): Checks if a column value is less than a specified value.
  • Greater than or equal to (>=): Checks if a column value is greater than or equal to a specified value.
  • Less than or equal to (<=): Checks if a column value is less than or equal to a specified value.

Filtering Examples

Let’s consider some examples of how to apply filters in SQL queries:

  • Filtering by a specific value:

SQL

SELECT * FROM customers WHERE city = 'New York';

This query selects all records from the customers table where the city column is equal to ‘New York’.

  • Filtering by a range of values:

SQL

SELECT * FROM products WHERE price BETWEEN 100 AND 200;

This query selects all records from the products table where the price column is between 100 and 200.

  • Filtering using multiple criteria:

SQL

SELECT * FROM orders WHERE status = 'Shipped' AND order_date > '2023-10-01';

This query selects all records from the orders table where the status column is equal to ‘Shipped’ and the order_date column is greater than ‘2023-10-01’.

Combining Filters with LIKE Operator

The LIKE operator is particularly useful for filtering data based on patterns or partial matches. It allows you to specify a pattern using wildcards, such as the percentage sign (%) to represent any number of characters.

  • Filtering using LIKE operator:

SQL

SELECT * FROM employees WHERE name LIKE '%Smith';

This query selects all records from the employees table where the name column contains the string ‘Smith’ anywhere in the value.

Conclusion

SQL filters are essential for retrieving specific and relevant data from databases. By utilizing the WHERE clause and various filter operators, you can refine your queries to extract the information you need for your analysis or tasks. Whether you’re filtering based on exact values, ranges, or patterns, SQL filters provide the flexibility to narrow down your results and gain valuable insights from your data.

One of the most powerful features
of SQL is its ability to filter. In this video, we’re going to learn how
this helps us make better queries and select more specific pieces
of data from a database. Filtering is selecting data
that match a certain condition. Think of filtering as a way of
only choosing the data we want. Let’s say we wanted to select
apples from a fruit cart. Filtering allows us to specify what
kind of apples we want to choose. When we go buy apples, we might explicitly
say, “Choose only apples that are fresh.” This removes apples that aren’t
fresh from the selection. This is a filter! As a security analyst, you might filter a
log-in attempts table to find all attempts from a specific country. This could be done by applying
a filter on the country column. For example, you could filter to just
return records containing Canada. Before we get started, we need to focus on an
important part of the syntax of SQL. Let’s learn about operators. An operator is a symbol or
keyword that represents an operation. An example of an operator would
be the equal to operator. For example,
if we wanted to find all records that have USA in the country
column, we use country = ‘USA’ To filter a query in SQL, we simply
add an extra line to the SELECT and FROM statement we used before. This extra line will use
a WHERE clause. In SQL, WHERE indicates the condition for a filter. After the keyword WHERE, the specific
condition is listed using operators. So if we wanted to find all of the login
attempts made in the United States, we would create this filter. In this particular condition, we’re
indicating to return all records that have a value in the country
column that is equal to USA. Let’s try putting it
all together in SQL. We’re going to start with
selecting all the columns from the log_in_attempts table. And
then add the WHERE filter. Don’t forget the semicolon! This tells us we finished
the SQL statement. Now, let’s run this query!
Because of our filter, only the rows where the country of the log-in
attempt was USA are returned. In the previous example, the condition for
our filter was based simply on returning records that are equal
to a particular value. We can also make our conditions
more complex by searching for a pattern instead of an exact word. For example, in the employees table,
we have a column for office. We could search for records in this
column that match a certain pattern. Perhaps we might want all
offices in the East building. To search for a pattern, we used the
percentage sign to act as a wildcard for unspecified characters. If we ran a filter for ‘East%’, this would
return all records that start with East — for example, the offices East-120,
East-290, and East-435. When searching for
patterns with the percentage sign, we cannot use the equals operator. Instead, we use another operator, LIKE. LIKE is an operator used with WHERE to
search for a pattern in a column. Since LIKE is an operator,
similar to the equal sign, we use it instead of the equal sign. So, when our goal is to return all values
in the office column that start with the word East, LIKE would
appear in a WHERE clause. Let’s go back to the example in
which we wanted to filter for log-in attempts made in the United States. Imagine that we realize that our database
contains inconsistencies with how the United States is represented. Some entries use US while others use USA. Let’s get into SQL and
apply this new type of filter with LIKE. We’re going to start with
the same first two lines of code because we want to select all
columns from the log-in attempts table. And we’re going to add a filter with
LIKE so that records will be returned if they contain a value in the country
column beginning with the characters US. This includes both US and USA. Let’s run this query to check if
the output changes. This returns all the entries where the user location
was in the United States. And now we can use the LIKE clause to
filter columns based on a pattern! Wow, we’ve already learned how to get
very precise with our database and get exactly the data we
need with one single query. I’m excited for what’s next!

Which WHERE clause contains the correct syntax to return all records that contain a value in the username column that starts with the character 'a'?

WHERE username LIKE ‘a%’;

WHERE username LIKE ‘a%’; contains the correct syntax to return all records that contain a value in the username column that starts with the character ‘a’. The LIKE operator is used with WHERE to search for a pattern in a column. The % wildcard substitutes for any number of other characters.

Reading: The WHERE clause and basic operators

Reading

Practice Quiz: Test your knowledge: SQL querie

What is filtering in SQL?

You are working with the Chinook database and want to return the firstname, lastname, and phone of all employees. Replace –??? with the missing information to complete the query. (If you want to undo your changes to the query, you can click the Reset button.)

A security analyst wants to filter the log_in_attempts table for records where the value in the country column is ‘Canada’. What is a valid query for this?

Which pattern matches with any string that starts with the character ‘A’?

More SQL filters


Video: Filter dates and numbers

In this video, the focus is on applying SQL queries and filters to new data types, specifically string, numeric, and date and time data. The tutorial introduces these data types and highlights their characteristics. It emphasizes the importance of working with numeric and date and time data in the context of security analysis.

Operators for filtering numeric and date and time data are discussed, including equals, greater than, less than, not equal to, greater than or equal to, and less than or equal to. The video illustrates how to construct SQL queries for filtering log-in attempts after 6 pm and finding patches installed within a specific date range using the BETWEEN operator.

The tutorial emphasizes the use of quotation marks for strings, dates, and times in filters but not for numbers. The viewer is prepared to apply these filtering techniques to various scenarios involving numeric and date data in SQL queries. The next video is teased to cover the expansion of filtering capabilities by using multiple conditions in a single query.

Filtering Dates

Filtering dates in SQL is a common task that is used to extract data from a database for a specific date or date range. There are two main operators that are used to filter dates in SQL:

  • The BETWEEN operator: The BETWEEN operator is used to select records where a date column is between two specified dates. For example, the following query selects all records from the orders table where the order_date column is between ‘2023-01-01’ and ‘2023-12-31’:

SQL

SELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31';
  • The LIKE operator: The LIKE operator is used to select records where a date column matches a pattern. For example, the following query selects all records from the orders table where the order_date column starts with the word ‘2023’:

SQL

SELECT * FROM orders WHERE order_date LIKE '2023%';

Filtering Numbers

Filtering numbers in SQL is also a common task that is used to extract data from a database for a specific number or range of numbers. There are several operators that are used to filter numbers in SQL:

  • The = operator: The = operator is used to select records where a number column is equal to a specified number. For example, the following query selects all records from the products table where the price column is equal to 100:

SQL

SELECT * FROM products WHERE price = 100;
  • The < operator: The < operator is used to select records where a number column is less than a specified number. For example, the following query selects all records from the products table where the price column is less than 50:

SQL

SELECT * FROM products WHERE price < 50;
  • The > operator: The > operator is used to select records where a number column is greater than a specified number. For example, the following query selects all records from the products table where the price column is greater than 150:

SQL

SELECT * FROM products WHERE price > 150;
  • The <= operator: The <= operator is used to select records where a number column is less than or equal to a specified number. For example, the following query selects all records from the products table where the price column is less than or equal to 100:

SQL

SELECT * FROM products WHERE price <= 100;
  • The >= operator: The >= operator is used to select records where a number column is greater than or equal to a specified number. For example, the following query selects all records from the products table where the price column is greater than or equal to 150:

SQL

SELECT * FROM products WHERE price >= 150;

Filtering Dates and Numbers Together

You can also use the AND and OR operators to filter dates and numbers together. For example, the following query selects all records from the orders table where the order_date column is between ‘2023-01-01’ and ‘2023-12-31’ and the price column is greater than or equal to 100:

SQL

SELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31' AND price >= 100;

I hope this tutorial has been helpful. Please let me know if you have any questions.

In this video, we’re going to continue
using SQL queries and filters, but now we’re going to apply
them to new data types. First, let’s explore the three
common data types that you will find in databases: string, numeric,
and date and time. String data is data consisting of
an ordered sequence of characters. These characters could be numbers,
letters, or symbols. For example, you’ll encounter
string data in user names, such as a user name: analyst10. Numeric data is data
consisting of numbers, such as a count of log-in attempts. Unlike strings, mathematical
operations can be used on numeric data, like multiplication or addition. Date and time data refers to data
representing a date and/or time. Previously, we applied filters
using string data, but now let’s work with numeric and
date and time data. As a security analyst, you’ll often
need to query numbers and dates. For example, we could filter patch dates
to find machines that need an update, or we could filter log-in
attempts to return only those made in a certain period of time. We learned about operators
in the last video, and we’re going to use them again for
numbers and dates. Common operators for
working with numeric or date and time data types include: equals,
greater than, less than, not equal to, greater than or
equal to, and less than or equal to. Let’s say you want to find the
log-in attempts made after 6 pm. Because this is past
normal business hours, you want to look for suspicious patterns. You can identify these attempts by using
the greater than operator in your filter. We’ll start writing our query in SQL. We begin by indicating that
we want to select all columns FROM the log_in_attempts table. Then we’ll add our filter with WHERE. Our condition indicates that the value in
the time column must be greater than, or for dates and times, later than ’18:00′,
which is how 6 pm is written in SQL. Let’s run this and examine the output. Perfect! Now we have a list of
log-in attempts made after 6 pm. We can also filter for numbers and
dates by using the BETWEEN operator. BETWEEN is an operator that filters for
numbers or dates within a range. An example of this would
be when looking for all patches installed
within a certain range. Let’s do this! Let’s find all
the patches installed between March 1st, 2021 and September 1st, 2021. In our query, we start with selecting
all records FROM the machines table. And we add the BETWEEN operator
in the WHERE statement. Let’s break down the statement. First, after WHERE, we indicate
which column to filter, in our case, OS_patch_date. Next, comes our operator BETWEEN. We then add the beginning of our range,
type AND, then finish by adding the end
of our range and a semicolon. Now, let’s run this and
explore the output. And now we have a list of all machines
patched between those two dates! Before we wrap up, an important thing to
note is that when we filter for strings, dates, and times, we use quotation marks
to specify what we’re looking for. However, for
numbers, we don’t use quotation marks. With this new knowledge, you’re now ready to work on all sorts of
interesting filters for numbers and dates. In the next video, we’ll be able to
expand our filtering even further by using multiple conditions in one query.

Which WHERE clause has the correct syntax to return all records that have a value of 5, 6, 7, or 8 in the event_id column?

WHERE event_id BETWEEN 5 AND 8;

WHERE event_id BETWEEN 5 AND 8; returns all records that have a value of 5, 6, 7, or 8 in the event_id column. The BETWEEN operator filters for values within a range. The BETWEEN operator is placed before the first value to be included in the range. This is followed by the AND operator and the last value to be included in the range.

Reading: Operators for filtering dates and numbers

Reading

Video: Filters with AND, OR, and NOT

This lesson delves into the utilization of the AND, OR, and NOT operators in SQL to meticulously filter queries. The AND operator enforces the requirement that both specified conditions must be simultaneously fulfilled. In contrast, the OR operator mandates that either one of the stipulated conditions be met. Conversely, the NOT operator effectively negates the specified condition, excluding any records that satisfy it.

To illustrate the application of the AND operator, consider a scenario where you seek to identify apples from a vast container solely comprising large and fresh apples. Employing the AND operator ensures that the retrieved results encompass exclusively large and fresh apples, eliminating any small apples, regardless of their freshness, or any rotten apples, irrespective of their size.

Moving on to the OR operator, imagine a situation where you aim to locate machines running either Operating System 1 or Operating System 3, as both require an urgent patch. Utilizing the OR operator ensures that the query results include machines equipped with either Operating System 1 or Operating System 3, encompassing all machines that meet either condition.

Finally, the NOT operator proves invaluable when you need to exclude specific records from a query. For instance, suppose you intend to update all devices in your company except those running Operating System 3. Leveraging the NOT operator effectively eliminates machines running Operating System 3 from the update process.

In essence, these operators empower you to refine queries with precision, enabling you to extract the precise information you seek from a vast dataset. As you continue your journey to becoming a proficient SQL analyst, mastering these operators will prove instrumental in crafting insightful and impactful queries.

Introduction

SQL filters are used to narrow down the results of a query based on specific criteria. In this tutorial, we will discuss three common SQL filters: AND, OR, and NOT.

The AND Operator

The AND operator is used to combine two or more conditions, and all of the conditions must be true for the record to be included in the results. For example, the following query selects all customers who live in California and have a credit score of over 700:

SQL

SELECT * FROM customers
WHERE state = 'CA' AND credit_score > 700;

The OR Operator

The OR operator is used to combine two or more conditions, and only one of the conditions needs to be true for the record to be included in the results. For example, the following query selects all customers who live in California or have a credit score of over 700:

SQL

SELECT * FROM customers
WHERE state = 'CA' OR credit_score > 700;

The NOT Operator

The NOT operator is used to negate a condition. For example, the following query selects all customers who do not live in California:

SQL

SELECT * FROM customers
WHERE state != 'CA';

Combining Filters

You can combine filters using parentheses to group conditions. For example, the following query selects all customers who live in California and either have a credit score of over 700 or are over the age of 50:

SQL

SELECT * FROM customers
WHERE state = 'CA' AND (credit_score > 700 OR age > 50);

Conclusion

Filters are a powerful tool for narrowing down the results of your SQL queries. By understanding the AND, OR, and NOT operators, you can write more complex and effective queries.

Examples

Here are some additional examples of how to use filters in SQL:

  • Select all products that are in stock and cost less than $50:

SQL

SELECT * FROM products
WHERE in_stock = 1 AND price < 50;
  • Select all orders that were placed in the year 2023:

SQL

SELECT * FROM orders
WHERE order_date >= '2023-01-01' AND order_date < '2024-01-01';
  • Select all employees who are not managers:

SQL

SELECT * FROM employees
WHERE is_manager = 0;

I hope this tutorial helps you learn how to use filters in SQL!

Additional Notes

  • You can also use the IN operator to check if a value is in a list of values. For example, the following query selects all customers who live in one of the following states: CA, NY, TX:

SQL

SELECT * FROM customers
WHERE state IN ('CA', 'NY', 'TX');
  • You can also use the BETWEEN operator to check if a value is within a range of values. For example, the following query selects all products that cost between $50 and $100:

SQL

SELECT * FROM products
WHERE price BETWEEN 50 AND 100;

In the previous lesson, we learned about even more
ways to filter queries in SQL to work with some typical
security analyst tasks. However, when working with
real security questions, we often have to filter
for multiple conditions. Vulnerabilities, for instance, might depend on more
than one factor. For example, a security vulnerability
might be related to machines using a
specific email client on a specific operating system. So, to find the possible
vulnerabilities, we need to find machines using both the email client and
the operating system. To make a query with multiple conditions
that must be met, we use the AND operator between
two separate conditions. AND is an operator
that specifies that both conditions must
be met simultaneously. Bringing this back to our
fruit and vegetable analogy, this is the same as asking
someone to select apples from the big box where the
apples are large and fresh. This means our results won’t
include any small apples even if they’re fresh, or any rotten apples even
if they’re large. They’ll only include
large fresh apples. The apples must meet
both conditions. Going back to our database, the machines table lists all operating systems
and email clients. We want a list of machines
running Operating System 1 and a list of machines
using Email Client 1. We’ll use the left
and right circles in the Venn diagram to
represent these groups. We need SQL to select
the machines that have both OS 1 and
Email Client 1. The filled-in area at
the intersection of these circles represents
this condition. Let’s take this and
implement it in SQL. First, we’re going to start by building the first
lines of the query, telling SQL to SELECT* all columns FROM the
machines table. Then, we’ll add the WHERE clause. Let’s examine this more closely. First, we indicate the first condition
that it must meet, that the operating system
column has a value of ‘0S 1’ Then, we use AND to join
this to another condition. And finally, we enter
the other condition, in this case that the email client column should have a value of ‘Email Client 1’ And this is how you use the
AND operator in SQL! Let’s run this to get
the query results. Perfect! All the results
match both our conditions! Let’s keep going and explore
more ways to combine different conditions by
working with the OR operator. The OR operator is
an operator that specifies that either
condition can be met. In a Venn diagram, let’s say each circle
represents a condition. When they are joined with OR, SQL would select all rows that satisfy one of the conditions. And it’s also ok if it
meets both conditions. Let’s run another query
and use the OR operator. Let’s say that we wanted the filter to identify
machines that have either OS 1 or OS 3 because
both types need a patch. We’ll type in these conditions. Let’s examine this more closely. After WHERE, our first
condition indicates we want to filter, so that the query
selects machines with ‘OS 1’ We use the OR operator
because we also want to find records that
match another condition. This additional condition
is placed after OR and indicates to also select
machines running ‘OS 3’ Executing the query, our results now include
records that have a value of either OS 1 or OS 3 in the
operating system column. Good job, we’re running
some complex queries. The last operator
we’re going to go into is the NOT operator. NOT negates a condition. In a diagram, we can show this by selecting every entry that does
not match our condition. The condition is
represented by the circle. The filled-in portion outside the circle represents
what gets returned. This is all data that does
not match the condition. For example, when
picking out fruit, you can be looking for any
fruit that is not an apple. That is a lot more efficient than telling your
friend you want a banana or an orange
or a lime, and so on. Suppose you wanted to update all of the devices in your company except for
the ones using OS 3. Bringing this into SQL, we can write this query. We place NOT after WHERE and before the
condition of the filter. Executing these queries
gives us the list of all the machines that
aren’t running OS 3, and now we know which
machines to update. That was a lot of new content
that we just looked into, but you’re learning more
and more SQL that you can use on your journey
to become an analyst! In the next video, we’ll be learning
how to combine and join two tables together to expand the kinds of queries we can
run. I’ll meet you there!

Why might a security analyst use the OR operator?

To find the ID numbers of all employees working in either the U.S. or Canada

A security analyst might use the OR operator to find the ID numbers of all employees working in either the U.S. or Canada. The OR operator specifies that either condition can be met.

Reading: More on filters with AND, OR, and NOT

Reading

Quiz: Portfolio Activity: Apply filters to SQL queries

Reading

Reading: Portfolio Activity Exemplar: Apply filters to SQL queries

Reading

Practice Quiz: Test your knowledge: More SQL filters

Which filter outputs all records with values in the date column between ’01-01-2015′ (January 1, 2015) and ’01-04-2015′ (April 1, 2015)?

Which operator is most efficient at returning all records with a status other than ‘successful’?

You are working with the Chinook database. You want to find the first and last names of customers who have a value in the country column of either ‘Brazil’ or ‘Argentina’. Replace –??? with the missing information to complete the query. (If you want to undo your changes to the query, you can click the Reset button.)

While working as an analyst, you encounter a query that includes the following filter:
SELECT *
FROM customers
WHERE country = ‘USA’ AND state = ‘NV’;
What will this query return?

SQL joins


Video: Join tables in SQL

Joining tables is a useful technique for combining information from two or more tables in a database. The syntax for joining tables is as follows:

SQL

SELECT column1, column2, ...
FROM table1
INNER JOIN table2
ON table1.column = table2.column;

The INNER JOIN keyword tells SQL to only return rows that have a matching value in both tables. The ON clause specifies the column that the join should be based on.

In the example given in the text, the employee_id column is used to join the employees and machines tables. The resulting query returns a list of users and their office location, along with the operating system they use on their machines.

Other types of joins, such as LEFT JOIN and RIGHT JOIN, will return rows even if there is no matching value in one of the tables. We will discuss these joins in the next video.

Combining Data from Multiple Tables: Mastering Joins in SQL

SQL, or Structured Query Language, serves as the foundation for interacting with relational databases. It enables users to manipulate, retrieve, and manage data stored within these databases. Among its capabilities, SQL excels at combining data from multiple tables using a powerful technique known as joining.

Understanding the Need for Joins

In relational databases, data is organized into tables, each containing specific information about a particular entity or aspect of a system. For instance, a database might have separate tables for employees, customers, orders, and products.

Often, queries require combining data from multiple tables to gain insights or perform comprehensive analyses. This is where joins come into play. Joins allow us to connect related data from different tables, providing a unified view of the information.

Types of Joins: Connecting Tables Effectively

SQL offers various types of joins, each serving a specific purpose in data retrieval and manipulation. Let’s explore the most common join types:

  1. INNER JOIN: This is the most fundamental join type, returning rows that have matching values in both tables. It ensures that only records with corresponding data are included in the results.
  2. LEFT JOIN: Unlike INNER JOIN, LEFT JOIN returns all rows from the left table, regardless of whether there’s a matching value in the right table. This means that even if no matching data exists, the left table’s rows will still be included in the result set.
  3. RIGHT JOIN: In contrast to LEFT JOIN, RIGHT JOIN returns all rows from the right table, regardless of whether there’s a matching value in the left table. This ensures that the right table’s rows are always included, even if there’s no corresponding data in the left table.
  4. FULL OUTER JOIN: This join combines the functionality of LEFT and RIGHT JOINs, returning all rows from both tables, regardless of whether there’s a matching value in the other table. It ensures that no rows are excluded, even if there’s no corresponding data in either table.

Implementing Joins in SQL: Practical Examples

To effectively utilize joins in SQL queries, understanding the syntax and application of each join type is crucial. Let’s consider some practical examples:

INNER JOIN: Suppose we have two tables, employees and departments, with corresponding columns employee_id and department_id. To retrieve employee names and their respective department names, we can use an INNER JOIN:

SQL

SELECT employees.name, departments.name
FROM employees
INNER JOIN departments ON employees.department_id = departments.department_id;

LEFT JOIN: Consider a scenario where we want to list all products, even if they have no associated orders. Using a LEFT JOIN, we can achieve this:

SQL

SELECT products.product_name, orders.order_id
FROM products
LEFT JOIN orders ON products.product_id = orders.product_id;

RIGHT JOIN: Imagine we need to display all customers, even if they haven’t placed any orders yet. A RIGHT JOIN can fulfill this requirement:

SQL

SELECT customers.name, orders.order_id
FROM customers
RIGHT JOIN orders ON customers.customer_id = orders.customer_id;

FULL OUTER JOIN: Suppose we want to list all employees and their corresponding managers, even if some employees don’t have a manager assigned. A FULL OUTER JOIN can handle this task:

SQL

SELECT employees.name, managers.name AS manager_name
FROM employees
FULL OUTER JOIN managers ON employees.manager_id = managers.manager_id;

Mastering Joins: Key Takeaways

  • Joins are essential for combining data from multiple tables in SQL.
  • Understand the purpose and syntax of different join types: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN.
  • Practice using joins in SQL queries to retrieve and analyze data effectively.
If you run the following query, what will it return? Select all that apply.
SELECT *

FROM log_in_attempts

INNER JOIN employees ON log_in_attempts.username = employees.username;
  • All rows in the log_in_attempts and employees tables that match on username
  • All columns in the log_in_attempts and employees tables

This query will return all rows in the log_in_attempts and employees tables that match on username and all columns in the log_in_attempts and employees tables. INNER JOIN returns rows matching on a specified column that exists in more than one table. It returns all columns that are indicated following the SELECT keyword. In this case, SELECT * indicates to return all columns.

You’ve already
learned a lot about SQL queries and
filters. Nice work! The last concept
we’re introducing in this section is joining tables
when querying a database. This is helpful when you need information from two different
tables in a database. Let’s say we have two tables: one that tells us about
security vulnerabilities of different operating
systems, and one about different machines
in our company, including their
operating systems. Having the ability
to combine them gives us a list of
vulnerable machines. That’s pretty cool, right? First, let’s start talking about
the syntax of joins. Since we’re working
with two tables now, we need a way to tell SQL what table we’re
picking columns from. In our example database, we have an employee_id column in both the employees table
and the machines table. In SQL statements that
contain two columns, SQL needs to know which
column we’re referring to. The way to resolve this is by writing the name of
the table first, then a period, and then
the name of a column. So, we would have employees
followed by a period, followed by the column name. This is the employee_id column
for the employees table. Similarly, this is the
employee_id column for the machines table. Now that we understand
this syntax, let’s apply it to a join! Imagine that we want to get a deeper understanding of the employees accessing the
machines in our company. By joining the employees and the machines tables,
we can do this! We first need to identify the shared column that we’ll use to connect the two tables. In this case, we’ll
use a primary key and one table to connect to another table where
it’s a foreign key. The primary key of the
employees table is employee_id, which is a foreign key
in the machines table. employee_id is a primary key in the employees
table because it has a unique value for every row in the employees table,
and no empty values. We don’t have a guarantee that
the employee_id column in the machines table follows the same criteria since it’s a foreign key and
not a primary key. Next, we’ll use a type of
join called an INNER JOIN. An INNER JOIN returns
rows matching on a specified column that exists
in more than one table. Tables usually contain
many more rows, but to further explain what
we mean by INNER JOIN, let’s focus on just
four rows from the employees table and four
rows from the machines table. We’ll also look at just a few columns of each
table for this example. Let’s say we choose employee_id in both tables
to perform an INNER JOIN. Let’s look at the two rows
where there is a match. Both tables have 1188 and 1189 in their respective
employee_id columns, so they are considered a match. The results of the join is
the two rows that have 1188 and 1189 and all columns
from both tables. Before we move on
to the queries, we have to talk about the
NULL values in the tables. In SQL, NULL represents a missing
value due to any reason. In this case, this might be machines that are not
assigned to any employee. Now, let’s bring this into SQL and do an INNER JOIN
on the full tables. Let’s imagine we want to join these tables in order to
get a list of users and their office location
that also shows what operating system they
use on their machines. employee_id is a common
column between these tables, and we can use this to join them. But we won’t need to show
this column in the results. First, let’s start
with a basic query that indicates we want
to select the username, office, and
operating_system columns. We want employees to be
our first or left table, so we’ll use that in our
FROM statement. Now, we write the part of
the query that tells SQL to join the machines table
with the employees table. Let’s break down this query. INNER JOIN tells SQL to
perform the INNER JOIN. Then, we name the second table we want to combine
with the first. This is called the right table. In this case, we want
to join machines with the employees table that was already identified after FROM. Lastly, we tell SQL what
column to base the join on. In our case, we’re using
the employee_id column. Since we’re using two tables, we have to identify the table and follow that with
the column name. So, we have employees.employee_id.
And machines.employee_id. Let’s review the output. Perfect! We have now
joined two tables. The results of our
query displays the records that match on
the employee_id column. Notice that these records contain columns
from both tables, but only the ones we’ve indicated through our
SELECT statement. There are other types
of joins that don’t require a match to
join two tables, and we’re going to discuss those in the next video. I’ll
meet you there!

Video: Types of joins

Outer Joins in SQL

Outer joins are a type of SQL join that returns all records from one or both tables, regardless of whether there is a matching value in the specified columns. There are three types of outer joins:

  • LEFT JOIN: Returns all records from the left table, and only matching records from the right table.
  • RIGHT JOIN: Returns all records from the right table, and only matching records from the left table.
  • FULL OUTER JOIN: Returns all records from both tables, regardless of whether there is a match.

Implementing Outer Joins in SQL

The syntax for implementing outer joins in SQL is the same as for INNER JOINs, but with the following keywords:

  • LEFT JOIN: LEFT JOIN
  • RIGHT JOIN: RIGHT JOIN
  • FULL OUTER JOIN: FULL OUTER JOIN

Benefits of Using Outer Joins

Outer joins can be useful for a variety of reasons, including:

  • Returning all records from one or both tables: This can be useful for getting a complete picture of the data, even if there are missing values.
  • Identifying records that do not have matching values: This can be useful for identifying potential problems or anomalies in the data.

Conclusion

Outer joins are an important tool for security analysts who use SQL. By understanding the different types of outer joins and how to implement them, security analysts can effectively query their data and gain valuable insights.

SQL Joins: Conquering the Art of Data Combination

In the realm of relational databases, data often resides across multiple tables. Joining, a fundamental SQL operation, enables us to seamlessly combine data from these tables, providing a unified view of the information.

Understanding the Need for Joins

Imagine a scenario where you need to retrieve customer information along with their respective orders. Customer data might be stored in a “customers” table, while order details reside in an “orders” table. To retrieve this combined information, we need to join these tables using the customer ID, which is a common attribute in both tables.

Types of Joins: Each with a Purpose

SQL offers various join types, each serving a specific purpose in data retrieval and manipulation. Let’s explore the most common join types:

INNER JOIN: The most fundamental join type, INNER JOIN returns rows that have matching values in both tables. It ensures that only records with corresponding data are included in the results.

SQL

SELECT customers.name, orders.order_id
FROM customers
INNER JOIN orders ON customers.customer_id = orders.customer_id;

LEFT JOIN: Unlike INNER JOIN, LEFT JOIN returns all rows from the left table, regardless of whether there’s a matching value in the right table. This means that even if no matching data exists, the left table’s rows will still be included in the result set.

SQL

SELECT customers.name, orders.order_id
FROM customers
LEFT JOIN orders ON customers.customer_id = orders.customer_id;

RIGHT JOIN: In contrast to LEFT JOIN, RIGHT JOIN returns all rows from the right table, regardless of whether there’s a matching value in the left table. This ensures that the right table’s rows are always included, even if there’s no corresponding data in the left table.

SQL

SELECT customers.name, orders.order_id
FROM customers
RIGHT JOIN orders ON customers.customer_id = orders.customer_id;

FULL OUTER JOIN: This join combines the functionality of LEFT and RIGHT JOINs, returning all rows from both tables, regardless of whether there’s a matching value in the other table. It ensures that no rows are excluded, even if there’s no corresponding data in either table.

SQL

SELECT customers.name, orders.order_id
FROM customers
FULL OUTER JOIN orders ON customers.customer_id = orders.customer_id;

Mastering Joins: Enhancing Data Analysis

Joins play a crucial role in data analysis, enabling us to combine data from multiple sources, uncover hidden patterns, and gain valuable insights. By understanding the different join types and their applications, we can effectively extract meaningful information from relational databases.

Conclusion: Joins as Pillars of SQL Expertise

Joins stand as fundamental building blocks of SQL proficiency, empowering users to connect and combine data from various tables. By mastering the different join types, we can transform raw data into actionable insights, driving informed decision-making.

What is the difference between an inner join and an outer join?

Inner joins only return rows that match on a specified column, but outer joins also return rows that don’t match on the specified column.

Inner joins only return rows that match on a specified column, but outer joins also return rows that don’t match on the specified column.

Welcome back. I hope you
enjoyed working on inner joins. In the previous video and exercises, we saw how
inner joins can be useful by only returning records that share a value
in specify columns. However, in some
situations, we might need all of the entries from
one or both of our tables. This is where we need
to use outer joins. There are three types of
outer joins: LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN. Similar to inner joins, outer joins combine
two tables together; however, they don’t
necessarily need a match between columns
to return a row. Which rows are returned
depends on the type of join. LEFT JOIN returns all of the
records of the first table, but only returns rows of the second table that match
on a specified column. Like we did in the
previous video, let’s examine this type of join by looking at just four rows of two tables with a small
number of columns. Employees is the left
table, or the first table, and machines is the right
table, or the second table. Let’s join on employee_id. There’s a matching value in this column for two
of the four records. When we execute the join, SQL returns these rows
with the matching value, all other rows from the left table, and all
columns from both tables. Records from the
employees table that didn’t match but were returned
through the LEFT JOIN contain NULL values in columns that came
from the machines table. Next, let’s talk
about right joins. RIGHT JOIN returns all of the records of
the second table but only returns rows from the first table that match
on a specified column. With a RIGHT JOIN on
the previous example, the full result returns
matching rows from both, all the rows from the second table, and all
the columns in both tables. For the values that don’t
exist in either table, we are left with a NULL value. Last, we’ll discuss
full outer joins. FULL OUTER JOIN
returns all records from both tables. Using
our same example, a FULL OUTER JOIN returns
all columns from all tables. If a row doesn’t
have a value for a particular column,
it returns NULL. For example, the machines table do not have any rows
with employee_id 1190, so the values
for that row and the columns that came from the
machines table is NULL. To implement left
joins, right joins, and full outer joins
in SQL, you use the same syntax structure
as the INNER JOIN but use these keywords: LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN. As a security analyst, you’re not required to know
all of these from memory. Once you understand the
type of join you need, you can quickly search and find all the information you need
to execute these queries. With this information on joins, we’ve now covered some
very important information you’ll need as a security
analyst using SQL. Thank you for joining
me in this video.

Reading: Compare types of joins

Reading

Practice Quiz: Test your knowledge: SQL joins

Which join types return all rows from only one of the tables being joined? Select all that apply.

You are performing an INNER JOIN on two tables on the employee_id column. The left table is employees, and the right table is machines. Which of the following queries has the correct INNER JOIN syntax?

In the following query, which join returns all records from the employees table, but only records that match on employee_id from the machines table?

As a security analyst, you are responsible for performing an INNER JOIN on the invoices and invoice_items tables of the Chinook database. These tables can be connected through the invoiceid column. Replace –??? with the missing information to complete the query. (If you want to undo your changes to the query, you can click the Reset button.)

Reading: Continuous learning in SQL

Reading

Review: Databases and SQL


Video: Wrap-up

This section focused on SQL, a tool that will help you on your journey as a security analyst. You learned about the structure of relational databases and how to access them using SQL. You also learned how to write SQL queries to bring up information you might need on the job. Additionally, you learned about SQL filters and how to use them to join multiple tables.

Congratulations! We’ve made it together through the end
of our focus on SQL. You’ve put in a lot of work and learned an
important tool that will help you on your journey
as a security analyst. Let’s take a moment
to go through all of the topics you
learned in this section. We started by learning about the structure of
relational databases and how we can access them by using the query language SQL. We then got hands-on practice with writing our
own SQL queries. We used SQL to bring up
information you might need on the job when
working as an analyst. We then focused on SQL filters. We started with simple
conditions with strings, and by the end, we
learned how to use multiple filters in one query. We concluded the unit with SQL joins and learned how to
join multiple tables, giving us even more
information at once. By completing this course, you just took a very big step in your future career as
a security analyst. You have been introduced to a powerful tool that can
help you in your work. Whenever you need to, I encourage you to revisit
the materials in this course. Learning a querying language
like SQL takes time. Thank you again for joining
me in this journey. I hope you’ll enjoy using
SQL as much as I do.

Reading: Reference guide: SQL

Reading

Reading: Glossary terms from module 4

Terms and definitions from Course 4, Module 4

Quiz: Module 4 challenge

Why might a security analyst use SQL?

What is true about the values in the primary key column? Select all that apply. 

Which of these SQL statements queries the machines table? Select all that apply. 

Both an employees table and a machines table contain an employee_id column, and you want to return only the records that share a value in this column. Which keyword should be part of your query?

What does WHERE department = ‘Sales’ indicate in the following SQL query?

You work with a table that has one column for name. Some of these names have prefixes. You want to identify all of the doctors. Which query will return every name that starts with the prefix ‘Dr.’?

You need to perform a SQL join. You want to return all the columns with records matching on the device_id column between the employees and machines tables. You also want to return all records from the employees table. Which of the following queries would you use?

You are working with the Chinook database. You want to return the lastname and title columns from the employees table. Replace –??? with the missing information to complete the query. (If you want to undo your changes to the query, you can click the Reset button.)

You are working with the Chinook database and are responsible for filtering for the employees with a birthdate that is on or after ‘1973-01-01’ (January 1, 1973). Replace –??? with the missing information to complete the query. (If you want to undo your changes to the query, you can click the Reset button.)

You are working with the Chinook database and are responsible for filtering for the customers that have a value of ‘USA’ in the country column and have a value of ‘Frank’ in the firstname column. Replace –??? with the missing information to complete the query. (If you want to undo your changes to the query, you can click the Reset button.)

Congratulations on completing Course 4!


Video: Course wrap-up

This course provided an introduction to computing basics for aspiring security analysts. It covered operating systems, Linux operating system, and SQL.

You made it to the
end of this course! Congratulations—you did it! I hope you are proud
of all you learned. The focus of this course
was computing basics. Understanding the basics of computing is a valuable skill as you transition into your
career as a security analyst. Let’s recap what you
learned in this course. We first focused on
operating systems and how they relate to
applications and hardware. Understanding how the
system you’re protecting works is essential for
doing your job effectively. That brings us to the
Linux operating system. When working in the
security profession, familiarity with
Linux is important. We first discussed
this architecture and various distributions. Then, we used a Linux
command line to carry out tasks you might encounter
as a security analyst. Finally, we looked at another useful tool and used
SQL to query databases. After this course, I hope you have a better
understanding of how these foundations
of computing support a security analyst
in their daily work. I also hope you continue
your path with this program. There are a lot of other useful and exciting topics ahead. Once again, congratulations. You’ve finished another course. Building skills is something
you should be proud of. Keep it up as you progress
through this program.

Reading: Course 4 glossary

Reading: Get started on the next course

Reading