Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Security Operation Center Analyst Level Three ยท Lesson 6 of 11

Module Five

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
6
Security Operation Centre Analyst โ€“ Module 5 (MySQL Advanced)

๐Ÿ—„๏ธ Module Five: Advanced MySQL for Security

Hello, data detective! In Module Four, you learned the basics of MySQL โ€“ how to create tables, add data, read data, update data, and delete data. Now, in Module Five, we will go further. We will learn advanced techniques to search, filter, and connect data. These skills will help you find hidden clues and investigate security incidents like a pro!


๐Ÿ“– Module Introduction

In Module Four, you learned the basic commands of MySQL. You learned how to create tables, add data, read data, update data, and delete data. But in real security investigations, we need more powerful tools. We need to search for patterns, find relationships, and analyse large amounts of data quickly.

In this module, we will learn advanced MySQL skills. We will learn how to use JOIN to combine tables, GROUP BY to group data, and subqueries to ask complex questions. We will also learn how to use MySQL to find suspicious patterns and investigate security incidents. By the end of this module, you will be a MySQL expert!

Remember: Great detectives connect the dots. MySQL helps you connect the dots!


๐ŸŽฏ Learning Objectives

After this module, you will be able to:

  • Use JOIN to combine data from multiple tables.
  • Use GROUP BY to group data and find patterns.
  • Use subqueries to ask complex questions.
  • Use advanced filtering with LIKE and wildcards.
  • Sort and limit results effectively.
  • Apply advanced MySQL skills to security investigations.
  • Analyse logs and find suspicious activities.

๐Ÿ“š Warm-up Story: Chidi's Cyber Investigation

Chidi is 10 years old and lives in Abuja. His school has a new computer lab. One day, the lab manager noticed that someone had been logging in late at night and trying to guess passwords. He had two tables of data: one with login logs and one with student information. But he couldn't figure out who the suspicious person was.

Chidi's older brother, Emeka, is a SOC Analyst. He came to help. He used a special MySQL command called JOIN to combine the two tables. He searched for all failed logins after 10 PM and connected them to student names. In just a few seconds, he found that only one student had failed logins late at night โ€“ a student who had been caught before.

Chidi was amazed. He asked Emeka to teach him advanced MySQL. Emeka said, "It's like putting together pieces of a puzzle. Let me show you how to use JOIN and GROUP BY!"

Question for you: Have you ever had to connect pieces of information to solve a puzzle?


๐Ÿงฉ Main Lessons

Lesson 1: Review โ€“ What We Learned in Module Four

Definition: In Module Four, we learned basic MySQL commands: CREATE TABLE, INSERT, SELECT, UPDATE, DELETE, WHERE, and ORDER BY.

Why it is important: These are the foundation for advanced commands.

Simple explanation: Before we learn to run, we need to learn to walk.

Real-life example: You use basic commands to create a table of students.

School example: You create a table of test scores.

Home example: You create a table of chores.

Nigerian example: You create a table of customers.

Basic Commands:
- CREATE TABLE
- INSERT INTO
- SELECT
- UPDATE
- DELETE
- WHERE
- ORDER BY

Mini summary: Basic commands are the building blocks of MySQL.


Lesson 2: What is a JOIN?

Definition: A JOIN combines data from two or more tables based on a common column.

Why it is important: JOIN helps us connect information that is stored in different tables.

Simple explanation: It's like matching puzzle pieces โ€“ you find the pieces that fit together.

Real-life example: Combining a table of students with a table of their grades.

School example: Combining a table of teachers with a table of classes.

Home example: Combining a table of family members with a table of chores.

Nigerian example: Combining a table of customers with a table of orders.

JOIN Example:
Students table: name, age, class_id
Classes table: class_id, class_name
JOIN them to get: name, age, class_name

Mini summary: JOIN helps us combine data from different tables.


Lesson 3: INNER JOIN โ€“ Matching Data

Definition: INNER JOIN returns only the rows that match in both tables.

Why it is important: It helps us find data that exists in both tables.

Simple explanation: It's like finding friends who have the same favourite colour.

Real-life example: Finding students who have grades recorded.

School example: Finding teachers who are assigned to a class.

Home example: Finding family members who have chores assigned.

Nigerian example: Finding customers who have placed orders.

INNER JOIN Syntax:
SELECT students.name, grades.grade
FROM students
INNER JOIN grades ON students.id = grades.student_id;

Mini summary: INNER JOIN matches data that exists in both tables.


Lesson 4: LEFT JOIN โ€“ Including Unmatched Data

Definition: LEFT JOIN returns all rows from the left table, and matching rows from the right table. If there is no match, it shows NULL.

Why it is important: It helps us find data that is missing from one table.

Simple explanation: It's like a guest list โ€“ you have all guests, and some might not have RSVP'd.

Real-life example: Finding students who have no grades recorded.

School example: Finding teachers who are not assigned to a class.

Home example: Finding family members who have no chores.

Nigerian example: Finding customers who have never placed an order.

LEFT JOIN Syntax:
SELECT students.name, grades.grade
FROM students
LEFT JOIN grades ON students.id = grades.student_id;

Mini summary: LEFT JOIN includes all rows from the left table, even if there's no match.


Lesson 5: GROUP BY โ€“ Grouping Data

Definition: GROUP BY groups rows that have the same value in a column. It is often used with aggregate functions like COUNT, SUM, AVG.

Why it is important: It helps us find patterns and summaries.

Simple explanation: It's like counting how many of each colour you have in a box of crayons.

Real-life example: Counting how many students are in each class.

School example: Finding the average test score for each subject.

Home example: Counting how many chores each person has.

Nigerian example: Counting how many orders each customer has placed.

GROUP BY Syntax:
SELECT class_id, COUNT(*) AS student_count
FROM students
GROUP BY class_id;

Mini summary: GROUP BY groups data and helps us find patterns.


Lesson 6: HAVING โ€“ Filtering Groups

Definition: HAVING is like WHERE, but it filters groups created by GROUP BY.

Why it is important: It helps us filter groups based on a condition.

Simple explanation: It's like saying "only show me groups that have more than 5 students."

Real-life example: Finding classes that have more than 20 students.

School example: Finding subjects with an average score above 80.

Home example: Finding family members with more than 5 chores.

Nigerian example: Finding customers with more than 10 orders.

HAVING Syntax:
SELECT class_id, COUNT(*) AS student_count
FROM students
GROUP BY class_id
HAVING student_count > 10;

Mini summary: HAVING filters groups based on a condition.


Lesson 7: Subqueries โ€“ Asking Complex Questions

Definition: A subquery is a query inside another query. It helps us ask complex questions.

Why it is important: It allows us to answer questions that need multiple steps.

Simple explanation: It's like asking a friend a question, and then asking them another question based on the answer.

Real-life example: Finding students who scored higher than the average.

School example: Finding subjects where the average score is above the overall average.

Home example: Finding chores that take longer than the average.

Nigerian example: Finding customers who have spent more than the average.

Subquery Syntax:
SELECT name FROM students
WHERE grade > (SELECT AVG(grade) FROM students);

Mini summary: Subqueries help us ask multiple-step questions.


Lesson 8: LIKE and Wildcards โ€“ Searching for Patterns

Definition: LIKE is used to search for a pattern in a column. Wildcards like % (any characters) and _ (one character) help us search.

Why it is important: It helps us find data that matches a pattern, not just an exact value.

Simple explanation: It's like finding all words that start with "A".

Real-life example: Finding all students whose names start with "A".

School example: Finding all emails that end with ".edu".

Home example: Finding all movies that start with "The".

Nigerian example: Finding all customers with "Lagos" in their address.

LIKE Syntax:
SELECT * FROM students WHERE name LIKE 'A%';
SELECT * FROM students WHERE email LIKE '%@gmail.com';

Mini summary: LIKE helps us search for patterns in data.


Lesson 9: LIMIT โ€“ Controlling Results

Definition: LIMIT restricts the number of rows returned by a query.

Why it is important: It helps us manage large datasets and see only the most important results.

Simple explanation: It's like only looking at the first page of a search result.

Real-life example: Showing only the top 10 students.

School example: Showing the top 5 test scores.

Home example: Showing the next 3 movies to watch.

Nigerian example: Showing the top 10 customers by spending.

LIMIT Syntax:
SELECT * FROM students ORDER BY grade DESC LIMIT 5;

Mini summary: LIMIT controls how many rows we see.


Lesson 10: Using JOIN, GROUP BY, and HAVING Together

Definition: We can combine JOIN, GROUP BY, and HAVING for powerful analysis.

Why it is important: It helps us answer complex security questions.

Simple explanation: It's like using all your detective tools at once.

Real-life example: Finding classes with more than 5 students who scored above 80.

School example: Finding subjects where the average score is above 75.

Home example: Finding family members with more than 3 chores and an average duration of 30 minutes.

Nigerian example: Finding customers who have placed more than 5 orders with a total spending above โ‚ฆ10,000.

Combined Query:
SELECT classes.name, COUNT(students.id) AS student_count, AVG(grades.grade) AS avg_grade
FROM classes
JOIN students ON classes.id = students.class_id
JOIN grades ON students.id = grades.student_id
GROUP BY classes.name
HAVING student_count > 5 AND avg_grade > 70;

Mini summary: Combining tools gives us powerful analysis.


Lesson 11: Using MySQL for Security Investigations โ€“ Login Logs

Definition: SOC Analysts use MySQL to analyse login logs and find suspicious activities.

Why it is important: It helps us detect and respond to security incidents.

Simple explanation: It's like searching for footprints to find the culprit.

Real-life example: Finding all failed login attempts after 10 PM.

School example: Finding who accessed a file after hours.

Home example: Finding who logged into a smart device.

Nigerian example: Finding suspicious transactions in a bank.

Security Query:
SELECT username, login_time, success
FROM login_logs
WHERE success = false AND login_time > '22:00:00'
ORDER BY login_time DESC;

Mini summary: MySQL helps us investigate security incidents.


Lesson 12: Using MySQL for Security Investigations โ€“ Multiple Tables

Definition: Sometimes we need to combine data from multiple tables to find suspicious patterns.

Why it is important: It helps us connect clues from different sources.

Simple explanation: It's like putting together puzzle pieces from different boxes.

Real-life example: Combining login logs with user information to find who made failed attempts.

School example: Combining access logs with student information.

Home example: Combining device logs with family member information.

Nigerian example: Combining transaction logs with customer information.

Security Query with JOIN:
SELECT users.name, logs.login_time, logs.success
FROM login_logs logs
JOIN users ON logs.user_id = users.id
WHERE logs.success = false
ORDER BY logs.login_time DESC;

Mini summary: Combining tables helps us find hidden connections.


Lesson 13: Finding Unusual Patterns

Definition: We can use advanced MySQL to find unusual patterns, like logins at odd times or from strange locations.

Why it is important: Unusual patterns often indicate a security threat.

Simple explanation: It's like noticing that someone is wearing a disguise.

Real-life example: Finding logins from a country where the company doesn't operate.

School example: Finding access to files that a student shouldn't see.

Home example: Finding a device that is online when no one is home.

Nigerian example: Finding transactions from unusual locations.

Unusual Pattern Query:
SELECT user_id, login_time, ip_address
FROM login_logs
WHERE login_time BETWEEN '00:00:00' AND '05:00:00'
AND ip_address NOT LIKE '192.168.%';

Mini summary: Advanced MySQL helps us find unusual patterns.


Lesson 14: Practice Makes Perfect

Definition: The more you practise advanced MySQL, the better you become at security investigations.

Why it is important: Practice helps you think like a detective and find clues faster.

Simple explanation: Like practising a sport โ€“ you get better with time.

Real-life example: A SOC Analyst practises queries every day.

School example: Students practise writing complex queries.

Home example: A parent practises with a home database.

Nigerian example: A bank analyst practises with customer data.

Practice Exercises:
- Write a query with JOIN and GROUP BY
- Write a query with a subquery
- Write a query with LIKE and wildcards
- Write a query with HAVING

Mini summary: Practice makes you a faster, better detective.


Lesson 15: You Are Now an Advanced MySQL User!

Definition: You have learned advanced MySQL skills. You can now investigate security incidents like a pro.

Why it is important: These skills are essential for any SOC Analyst.

Simple explanation: You are now a master of data โ€“ you can find hidden clues.

Real-life example: You can help a company investigate a security breach.

School example: You can help your school analyse access logs.

Home example: You can help your family monitor their devices.

Nigerian example: You can help a bank detect fraud.

You โ†’ Learned Advanced MySQL โ†’ Can Investigate Threats! ๐Ÿ•ต๏ธโ€โ™‚๏ธ

Mini summary: You are now an advanced MySQL user โ€“ ready to investigate!


๐Ÿ“Œ Key Vocabulary (with simple definitions)

  • JOIN: Combines data from two or more tables.
  • INNER JOIN: Shows only matching rows.
  • LEFT JOIN: Shows all rows from the left table, even if no match.
  • GROUP BY: Groups rows with the same value.
  • HAVING: Filters groups created by GROUP BY.
  • Subquery: A query inside another query.
  • LIKE: Searches for a pattern.
  • Wildcard: A symbol that represents characters (%, _).
  • LIMIT: Restricts the number of rows returned.
  • Aggregate Function: A function that works on groups (COUNT, SUM, AVG).

๐Ÿง  Important Concepts

  • Concept 1: JOIN connects tables. It helps us see the bigger picture.
  • Concept 2: GROUP BY reveals patterns. It helps us see trends.
  • Concept 3: Subqueries ask detailed questions. They help us dig deeper.
  • Concept 4: LIKE searches for patterns. It helps us find specific clues.
  • Concept 5: Practice is essential. The more you use MySQL, the better you get.

๐Ÿชœ Step-by-Step: How to Write a Security Query with JOIN

  1. Identify what you want to find. Example: Find all failed logins and the user names.
  2. Identify the tables you need. You need login_logs and users.
  3. Find the common column. Both tables have a user_id column.
  4. Write the SELECT statement. SELECT users.name, logs.login_time
  5. Use JOIN to combine the tables. JOIN users ON logs.user_id = users.id
  6. Add a WHERE condition. WHERE logs.success = false
  7. Sort the results. ORDER BY logs.login_time DESC
  8. Run the query. You now have a list of failed logins and the users who made them.
Step 1: Find failed logins and user names
Step 2: Tables: login_logs, users
Step 3: Common column: user_id
Step 4: SELECT users.name, logs.login_time
Step 5: JOIN users ON logs.user_id = users.id
Step 6: WHERE logs.success = false
Step 7: ORDER BY logs.login_time DESC
Step 8: Run the query!

๐ŸŒ Real-life Examples

  • Example 1: A company uses JOIN to combine employee tables with access logs.
  • Example 2: A hospital uses GROUP BY to find which doctors have the most patients.
  • Example 3: A bank uses subqueries to find customers who have made suspicious transactions.

๐Ÿ‡ณ๐Ÿ‡ฌ Nigerian Examples

  • Example 1: A Nigerian bank uses JOIN to combine customer tables with transaction logs to find fraud.
  • Example 2: A Nigerian telecom company uses GROUP BY to find which regions have the most network issues.
  • Example 3: A Nigerian e-commerce site uses subqueries to find customers who have spent more than average.

๐ŸŽˆ Fun Examples children can relate to

  • Fun Example 1: You have a table of friends and a table of favourite games. You use JOIN to find which friends like the same games.
  • Fun Example 2: You have a table of homework assignments and a table of subjects. You use GROUP BY to find which subject has the most homework.
  • Fun Example 3: You have a table of toys and a table of colours. You use LEFT JOIN to find toys that don't have a colour listed.

๐Ÿ  Everyday Examples

  • Everyday 1: A family uses JOIN to combine a chore table with a family member table.
  • Everyday 2: A parent uses GROUP BY to find which child has the most chores.
  • Everyday 3: A family uses LIKE to find all movies that start with "The".

๐Ÿ‘ฉโ€๐Ÿซ Teacher Notes

  • Use the warm-up story to introduce the concept of JOIN.
  • Encourage students to practise writing complex queries.
  • Use analogies like puzzle pieces to explain JOIN and GROUP BY.
  • Provide hands-on activities with sample data.
  • Connect advanced SQL to real-world security scenarios.

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Parent Tips

  • Help your child understand JOIN by using real-life examples (e.g., matching a person to their favourite colour).
  • Encourage your child to practice writing queries on a computer.
  • Discuss how companies use advanced SQL to investigate problems.
  • Support your child's interest in security and data analysis.

โœจ Interesting Facts

  • Fact 1: Many large companies use JOIN to combine data from hundreds of tables.
  • Fact 2: GROUP BY is used to create daily, weekly, and monthly reports.
  • Fact 3: Subqueries can be nested โ€“ one query inside another inside another.
  • Fact 4: Security Analysts often use LIKE to search for suspicious IP addresses.

๐Ÿ’ก Did You Know?

  • Did you know that you can combine multiple tables using more than one JOIN?
  • Did you know that GROUP BY can be used with COUNT, SUM, AVG, MIN, and MAX?
  • Did you know that security investigations often involve analyzing millions of rows of data?
  • Did you know that some SQL queries can take minutes or even hours to run on very large datasets?

๐Ÿ”” Remember This

  • JOIN combines data from multiple tables.
  • INNER JOIN shows only matching rows.
  • LEFT JOIN includes all rows from the left table.
  • GROUP BY groups data.
  • HAVING filters groups.
  • Subqueries ask complex questions.
  • LIKE searches for patterns.
  • LIMIT controls the number of rows.
  • Practice makes you an expert.

โš ๏ธ Common Mistakes

  • Mistake 1: Forgetting the JOIN condition (ON clause).
  • Mistake 2: Using HAVING without GROUP BY.
  • Mistake 3: Forgetting to include all columns in GROUP BY.
  • Mistake 4: Using LIKE with too many wildcards, which slows down queries.
  • Mistake 5: Not using LIMIT on large queries.

๐ŸŒŸ Best Practices

  • Practice 1: Always use table aliases (e.g., t1, t2) to make queries easier to read.
  • Practice 2: Test queries on a small dataset first.
  • Practice 3: Use comments to explain complex queries.
  • Practice 4: Always use WHERE with UPDATE and DELETE.
  • Practice 5: Back up data before running complex updates or deletes.

๐Ÿ“Š Illustrations & Tables

Flowchart: Advanced Query Process

  Identify Question
        |
        V
  Identify Tables
        |
        V
  Choose JOIN Type
        |
        V
  Write SELECT Statement
        |
        V
  Add GROUP BY (if needed)
        |
        V
  Add HAVING (if needed)
        |
        V
  Add ORDER BY
        |
        V
  Run Query
        |
        V
  Analyse Results

Comparison Table: JOIN Types

JOIN Type What It Returns Use Case
INNER JOIN Only matching rows Find students with grades
LEFT JOIN All rows from left table Find students without grades
RIGHT JOIN All rows from right table Rarely used
FULL JOIN All rows from both tables Not supported in MySQL

Table: Aggregate Functions

Function What It Does Example
COUNT Counts rows COUNT(*)
SUM Adds values SUM(amount)
AVG Calculates average AVG(grade)
MIN Finds minimum MIN(grade)
MAX Finds maximum MAX(grade)

Timeline: Your Advanced MySQL Journey

Lesson 1: Review basic commands
    |
Lesson 2: Introduction to JOIN
    |
Lesson 3: INNER JOIN
    |
Lesson 4: LEFT JOIN
    |
Lesson 5: GROUP BY
    |
Lesson 6: HAVING
    |
Lesson 7: Subqueries
    |
Lesson 8: LIKE and Wildcards
    |
Lesson 9: LIMIT
    |
Lesson 10: Combining commands
    |
Lesson 11: Security with MySQL (Logs)
    |
Lesson 12: Security with MySQL (Multiple tables)
    |
Lesson 13: Finding unusual patterns
    |
Lesson 14: Practice
    |
YOU ARE AN ADVANCED MYSQL USER! ๐ŸŽ‰

๐Ÿ“ End-of-Module Summary

Congratulations! You have completed Module Five of your Security Operation Centre Analyst training. You have learned advanced MySQL skills โ€“ JOIN, GROUP BY, HAVING, subqueries, LIKE, wildcards, and LIMIT. You have learned how to combine data from multiple tables, group data to find patterns, and ask complex questions. You have also learned how to use these skills in security investigations. You are now a true MySQL expert!


โ“ Frequently Asked Questions (FAQs)

  1. Q: What is a JOIN?
    A: JOIN combines data from two or more tables.
  2. Q: What is the difference between INNER JOIN and LEFT JOIN?
    A: INNER JOIN shows only matching rows; LEFT JOIN shows all rows from the left table.
  3. Q: What does GROUP BY do?
    A: It groups rows that have the same value in a column.
  4. Q: What is the difference between WHERE and HAVING?
    A: WHERE filters rows; HAVING filters groups.
  5. Q: What is a subquery?
    A: A query inside another query.
  6. Q: What does LIKE do?
    A: It searches for a pattern in a column.
  7. Q: What are wildcards?
    A: Symbols like % (any characters) and _ (one character).
  8. Q: What does LIMIT do?
    A: It restricts the number of rows returned.
  9. Q: How do SOC Analysts use advanced MySQL?
    A: To investigate security incidents and find suspicious patterns.
  10. Q: How can I practise advanced MySQL?
    A: By writing queries on sample data and solving problems.

๐Ÿ“ Review Questions (15)

  1. What is a JOIN?
  2. What is the difference between INNER JOIN and LEFT JOIN?
  3. What does GROUP BY do?
  4. What is the difference between WHERE and HAVING?
  5. What is a subquery?
  6. What does LIKE do?
  7. What are wildcards?
  8. What does LIMIT do?
  9. How do you use JOIN with GROUP BY?
  10. How do you use HAVING with GROUP BY?
  11. How can MySQL help in security investigations?
  12. Give an example of a security query with JOIN.
  13. Why is practice important in learning MySQL?
  14. What is an aggregate function?
  15. Name two aggregate functions.

โœ๏ธ Fill-in-the-Blank

  1. ______ combines data from multiple tables.
  2. ______ JOIN shows only matching rows.
  3. ______ JOIN shows all rows from the left table.
  4. ______ groups rows with the same value.
  5. ______ filters groups created by GROUP BY.
  6. A ______ is a query inside another query.
  7. ______ searches for a pattern in a column.
  8. ______ restricts the number of rows returned.
  9. COUNT, SUM, and AVG are ______ functions.
  10. ______ Analysts use advanced MySQL to investigate incidents.
  11. ______ is a wildcard that represents any characters.
  12. ______ is a wildcard that represents one character.
  13. Always use ______ with UPDATE and DELETE.
  14. ______ makes you a better MySQL user.
  15. You are now an ______ MySQL user.

โœ… True or False

  1. JOIN combines data from multiple tables. (True)
  2. INNER JOIN shows all rows from the left table. (False)
  3. LEFT JOIN shows only matching rows. (False)
  4. GROUP BY groups rows with the same value. (True)
  5. HAVING filters rows. (False)
  6. A subquery is a query inside another query. (True)
  7. LIKE searches for an exact match. (False)
  8. LIMIT restricts the number of rows returned. (True)
  9. COUNT is an aggregate function. (True)
  10. Security Analysts do not use MySQL. (False)

๐Ÿ”˜ Multiple Choice Questions

  1. What combines data from multiple tables?
    A) JOIN
    B) GROUP BY
    C) WHERE
    Answer: A
  2. Which JOIN shows only matching rows?
    A) LEFT JOIN
    B) INNER JOIN
    C) RIGHT JOIN
    Answer: B
  3. Which JOIN shows all rows from the left table?
    A) LEFT JOIN
    B) INNER JOIN
    C) GROUP BY
    Answer: A
  4. What groups rows with the same value?
    A) JOIN
    B) GROUP BY
    C) ORDER BY
    Answer: B
  5. What filters groups?
    A) WHERE
    B) HAVING
    C) ORDER BY
    Answer: B
  6. What is a subquery?
    A) A query inside another query
    B) A query with GROUP BY
    C) A query with LIMIT
    Answer: A
  7. What searches for a pattern?
    A) =
    B) LIKE
    C) IN
    Answer: B
  8. What restricts the number of rows?
    A) LIMIT
    B) GROUP BY
    C) HAVING
    Answer: A
  9. What is an aggregate function?
    A) COUNT
    B) LIKE
    C) WHERE
    Answer: A
  10. How do SOC Analysts use MySQL?
    A) To play games
    B) To investigate incidents
    C) To design websites
    Answer: B
  11. Which wildcard represents any characters?
    A) _
    B) %
    C) *
    Answer: B
  12. Which wildcard represents one character?
    A) _
    B) %
    C) *
    Answer: A
  13. What does SUM do?
    A) Counts rows
    B) Adds values
    C) Averages values
    Answer: B
  14. What does AVG do?
    A) Counts rows
    B) Adds values
    C) Averages values
    Answer: C
  15. What is the best way to learn MySQL?
    A) Reading only
    B) Practising with queries
    C) Watching videos
    Answer: B

๐Ÿ”— Matching Exercise

Match the command to its description:

Command Description
JOIN Combines tables
GROUP BY Groups rows
HAVING Filters groups
LIKE Searches for a pattern
LIMIT Restricts rows

โœ๏ธ Short Answer Questions

  1. What is the difference between INNER JOIN and LEFT JOIN?
  2. How do you use GROUP BY with HAVING?
  3. What is a subquery?
  4. How can MySQL help in security investigations?
  5. Why is practice important in learning MySQL?

๐ŸŽญ Scenario-based Exercises

Scenario 1: You are a SOC Analyst. You have two tables: login_logs (user_id, login_time, success) and users (id, name). Write a query to find all failed logins after 10 PM and the user names.

Scenario 2: You have a table of transactions (customer_id, amount, date). Write a query to find the total spending for each customer, and only show customers who have spent more than โ‚ฆ10,000.

Scenario 3: You have a table of emails (id, sender, subject). Write a query to find all emails that contain the word "phishing" in the subject.


๐Ÿ‘ฅ Group Activity

Security Investigation Challenge: In groups of 4, you are given a sample database with login logs, user information, and transaction data. Your task is to write queries to find suspicious activities โ€“ failed logins, unusual transaction amounts, and logins from unusual locations. Present your findings to the class.


๐Ÿง‘โ€๐ŸŽ“ Individual Activity

My Advanced SQL Practice: Create a database with at least two tables (e.g., students and grades). Write queries that use JOIN, GROUP BY, HAVING, subqueries, and LIKE. Write a report on what you found.


๐Ÿ’ฌ Classroom Discussion Questions

  1. Why is JOIN important in security investigations?
  2. How can GROUP BY help find patterns?
  3. When would you use a subquery instead of a JOIN?
  4. How can LIKE be used to find suspicious emails?
  5. What would you do if a query was too slow?

๐Ÿ› ๏ธ Mini Project: Security Log Analysis

Task: Create a security log database with tables for login logs, user information, and IP addresses. Write at least 5 advanced queries to find suspicious activities, such as failed logins, logins from unusual countries, and users with multiple failed attempts. Present your queries and findings.


๐Ÿ“‹ Practical Assignment

Assignment: Write a report on a real-world security incident that could have been detected using MySQL. Explain how MySQL queries could have been used to identify the suspicious activity.


๐Ÿ† Challenge Exercise

Challenge: Write a complex MySQL query that finds all users who have had more than 3 failed login attempts in the last 24 hours, and then joined by a user who logged in successfully from a different IP address within 5 minutes. Use JOIN, GROUP BY, HAVING, and subqueries.


๐Ÿ”‘ Quiz Answers

Fill-in-the-Blank Answers: 1. JOIN, 2. INNER, 3. LEFT, 4. GROUP BY, 5. HAVING, 6. subquery, 7. LIKE, 8. LIMIT, 9. aggregate, 10. Security, 11. %, 12. _, 13. WHERE, 14. Practice, 15. advanced.

True or False: 1T, 2F, 3F, 4T, 5F, 6T, 7F, 8T, 9T, 10F.

Multiple Choice Answers: 1A, 2B, 3A, 4B, 5B, 6A, 7B, 8A, 9A, 10B, 11B, 12A, 13B, 14C, 15B.


๐ŸŽ Key Takeaways

  • JOIN combines data from multiple tables.
  • INNER JOIN shows only matching rows.
  • LEFT JOIN includes all rows from the left table.
  • GROUP BY groups data and reveals patterns.
  • HAVING filters groups.
  • Subqueries help ask complex questions.
  • LIKE searches for patterns.
  • LIMIT controls how many rows you see.
  • Advanced MySQL is essential for security investigations.
  • Practice is key to mastering MySQL.

๐Ÿš€ Preparation for Module Six

In Module Six, we will learn about threat detection tools and how SOC Analysts use them to monitor networks and detect attacks. We will look at tools like SIEM, intrusion detection systems, and endpoint detection. We will also learn how to use MySQL to analyse security data.

Before next class: Think about how you would monitor a network for suspicious activities. What would you look for? We will explore this together in the next module.


๐Ÿ—„๏ธ You have completed Module Five โ€“ keep up the great work! ๐Ÿ—„๏ธ

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’