Enter answer here
1 point
3.
Question 3
True or False: NOT NULL, UNIQUE, and FOREIGN KEY are commonly used constraints in MySQL.
True
False
1 point
4.
Question 4
The following SQL statement must apply a check constraint on the “Age” column of the “Customers” table to ensure that all customers are 21 years of age or older. Identify the missing keyword to create this constraint.
Assistant
User
Question 1
Write the expected output of the following CONCAT function:
SELECT CONCAT ("4", "/", "4", "= ?");
Enter answer here
1 point
2.
Question 2
Select the function name that changes the first-string value of columnA with the second string value in the following SQL statement:
1 point
3.
Question 3
Which of the following functions is a numerical math function that returns the remainder of one number divided by another?
MOD( )
FORMAT( )
AVG( )
1 point
4.
Question 4
Which of the following functions are commonly used in MySQL to add IF-THEN-ELSE logic to SQL queries? Select all that apply.
NULLIF
Assistant
User
Question 1
The manager of ‘Little Lemon’ restaurant needs to view all bookings from 2021-10-10 to 2021-10-20. Which of the following SQL statements can be used to complete this task? Select all that apply.
1
SELECT * FROM Orders WHERE BookingDate > ‘2021-10-10’ AND BookingDate < ‘2021-10-20’;
1
SELECT * FROM Bookings WHERE BookingDate BETWEEN ‘2021-10-10’ AND ‘2021-10-20’;
1
SELECT * FROM Orders WHERE BookingDate >= ‘2021-10-10’ AND BookingDate <= ‘2021-10-20’;
1 point
2.
Question 2
Complete the following statement: A join in a database joins records of data between one or multiple tables based on a _______________ column.
Assistant
User
Question 1
You can use MySQL stored procedures and functions to call a code block to perform a specific operation by invoking the identifier name.
True
False
1 point
2.
Question 2
Your MySQL database contains a stored procedure called GetProductDetails(). What keyword can you use to invoke this stored procedure in the following statement?
Assistant
User
Question 1
In a SELECT statement, the use of functions and wildcards in predicates could hinder the performance of column indexes.
False
True
1 point
2.
Question 2
Which of the following statements apply to MySQL indexes? Select all that apply.
Data stored in the index is always sorted.
An index can be created on only one column of a table.
An index is a data structure that helps maintain pointers to data in a table.
Primary indexes are created programmatically while secondary indexes are created automatically.
Assistant
User
Question 1
The relational database model in MySQL makes it easy for users to access, retrieve and analyze data in MySQL.
False
True
1 point
2.
Question 2
Which type of data analysis is used to investigate data and identify relationships between different variables in the database?
_______ data analysis.
Enter answer here
1 point
3.
Question 3
Which of the following types of data analysis uses existing data to find paradigms and patterns to make predictions about an organization’s performance and progress?
Assistant
User
Question 1
You need to create a stored procedure that contains multiple statements. Which of the following steps can you take to complete this task? Select all that apply.
Return a value using the RETURN command.
Define the procedure’s body using the BEGIN END keywords.
Assistant
Table of Employees with the columns of ID, name, date and working hours
HAVING
GROUP
1 point
Here are the answers to the questions:
Question 1:
True or False: AND, OR, NOT, IN, BETWEEN, and LIKE operators are all used to combine multiple filter conditions in the WHERE clause. Answer: True
Question 2:
What should be the correct WHERE clause condition to filter out customers who are not from any of these countries – USA, UK. Answer: WHERE NOT(Country = 'USA' OR Country = 'UK');
Question 3:
If this query is written based on the Products table below, what would be the result? SELECT quantity from Products WHERE quantity BETWEEN 2000 AND 8000; Answer: 2000, 5000, 8000
(Records within the specified range from 2000 to 8000, inclusive.)
Question 4:
What is the result of the following query when enacted on the Author table? SELECT Author_name FROM Author WHERE Author_name LIKE '%an'; Answer: S.B. Swaminathan, Thomas Morgan
(The %an matches author names ending with "an".)
Question 5:
True or False: There is no SELF JOIN clause in MySQL. Answer: True
(There is no specific SELF JOIN keyword in MySQL; a self-join is achieved by aliasing the same table.)
Question 6:
A database contains two tables [orders and suppliers], and the resulting table only keeps records that match between the two tables.
What type of JOIN has been performed here? Answer: INNER JOIN
(The INNER JOIN only includes records where there is a match in both tables.)
Question 7:
What JOIN keywords can be used to perform a SELF JOIN? Select all that apply. Answer: INNER JOIN, LEFT JOIN, RIGHT JOIN
(Since a self-join uses the same table, all these types of joins can be applied depending on the desired output.)
Question 8:
How many tables do you need to create a SELF JOIN? Answer: One table
(Self-join queries use one table, but the table is aliased to make it behave as two separate tables.)
Question 9:
True or False: This SQL statement finds out the number of orders made by each customer. SELECT COUNT(*) FROM Orders GROUP BY customerID; Answer: True
(Using GROUP BY customerID groups the data by each customer, and COUNT(*) counts the number of orders per group.)
Question 10:
Select the missing SQL keyword to find the employees who have worked for more than 12 hours in total. SELECT Emp_Name, SUM(Working_Hours) FROM Timesheet GROUP BY Emp_Name _________ SUM(Working_Hours) > 12; Answer: HAVING
(The HAVING clause is used to filter aggregated results after grouping.)
1
CREATE TABLE Customers (ID INT NOT NULL, FullName VARCHAR (255), Age INT, ____ (Age >= 21));
Enter answer here
1 point
5.
Question 5
What kind of changes can the ALTER TABLE statement make in the database? Select all that apply.
Change columns and tables names.
Add and drop various constraints on an existing table.
Add, delete, and modify columns in an existing table.
1 point
6.
Question 6
True or False: To create a new column in an existing table you must use the ALTER TABLE with the MODIFY command.
True
False
1 point
7.
Question 7
True or False: Copying data from one table to another table in MySQL can be done only if both tables exist in the same database.
True
False
1 point
8.
Question 8
What type of query is placed after the operator in the following SQL statement?
1
SELECT name FROM Products WHERE price = (SELECT MAX (price) FROM Products);
Inner query
Outer query
1 point
9.
Question 9
Write the SQL keyword to create the Products virtual table in MySQL.
1
CREATE ___________ ProductsVirtualTable;
Enter answer here
1 point
10.
Question 10
What are the key benefits of a virtual table? Select all that apply.
Simplify access to the data in the database
Support database security
Manipulate data in the base table
1 point
Here are the answers to the questions:
Question 1:
True or False: The MySQL REPLACE statement can be used to insert and update data in the database tables. Answer: True
(The REPLACE statement inserts a new row or updates an existing one if a primary or unique key match occurs.)
Question 2:
Text match. Type the missing command name in the following SQL statement to change the record of data where staffID = 10: ______________ INTO Staff(staffID, FullName, Salary) VALUES (10, “Mark Carlson”, 30000); Answer: REPLACE
(The REPLACE keyword is used to insert or update the row when the specified primary or unique key already exists.)
Question 3:
True or False: NOT NULL, UNIQUE, and FOREIGN KEY are commonly used constraints in MySQL. Answer: True
(These are frequently used constraints to enforce data integrity in databases.)
Question 4:
The following SQL statement must apply a check constraint on the Age column of the Customers table to ensure that all customers are 21 years of age or older. Identify the missing keyword to create this constraint: CREATE TABLE Customers (ID INT NOT NULL, FullName VARCHAR (255), Age INT, ____ (Age >= 21)); Answer: CHECK
(The CHECK keyword is used to enforce conditions on a column's values.)
Question 5:
What kind of changes can the ALTER TABLE statement make in the database? Select all that apply. Answer(s):
Change columns and table names
Add and drop various constraints on an existing table
Add, delete, and modify columns in an existing table
(The ALTER TABLE statement allows for modifying table structure, such as constraints and columns.)
Question 6:
True or False: To create a new column in an existing table you must use the ALTER TABLE with the MODIFY command. Answer: False
(The ADD command under ALTER TABLE is used to create a new column, not MODIFY.)
Question 7:
True or False: Copying data from one table to another table in MySQL can be done only if both tables exist in the same database. Answer: False
(Data can be copied across tables in different databases by specifying the database name explicitly, e.g., database1.table1.)
Question 8:
What type of query is placed after the operator in the following SQL statement? SELECT name FROM Products WHERE price = (SELECT MAX(price) FROM Products); Answer: Inner query
(The query inside parentheses is a subquery or inner query.)
Question 9:
Write the SQL keyword to create the Products virtual table in MySQL: CREATE ___________ ProductsVirtualTable; Answer: VIEW
(A view is a virtual table that represents the result of a stored query.)
Question 10:
What are the key benefits of a virtual table? Select all that apply. Answer(s):
Simplify access to the data in the database
Support database security
Manipulate data in the base table
(A virtual table, or view, simplifies complex queries, enforces security by restricting access, and can be used to manipulate the underlying data.)
IFNULL
IF
1 point
5.
Question 5
Type the output value of the following SQL statement with the IFNULL function:
SELECT IFNULL (NULL, ‘IFNULL’);
Enter answer here
1 point
6.
Question 6
True or False: A stored procedure is a prepared SQL code that can be saved and reused by calling the procedure identifier name.
True
False
1 point
7.
Question 7
The following SQL statement creates a procedure that returns all names from Clients table. Write the missing keyword to create the procedure.
CREATE _______ GetClientsNames() SELECT names FROM Clients;
Enter answer here
1 point
8.
Question 8
How many parameters can you use in MySQL stored procedure? Select all that apply.
One
Many
Zero
1 point
9.
Question 9
Select the correct option to invoke a stored procedure:
SELECT procedure_name();
SELECT procedure_name;
CALL procedure_name();
CALL procedure_name;
1 point
10.
Question 10
What is the output of the following stored procedure when the number 5 is passed as an argument to the xNumber parameter?
Write the expected output of the following CONCAT function: SELECT CONCAT ("4", "/", "4", "= ?"); Answer: 4/4= ?
(The CONCAT function concatenates strings, so the result is 4/4= ?.)
Question 2:
Select the function name that changes the first-string value of columnA with the second string value in the following SQL statement: ___________ (columnA, firstStringValue, secondStringValue) Answer: REPLACE()
(The REPLACE function replaces all occurrences of the first string with the second string in the specified column.)
Question 3:
Which of the following functions is a numerical math function that returns the remainder of one number divided by another? Answer: MOD()
(The MOD() function calculates the remainder of one number divided by another.)
Question 4:
Which of the following functions are commonly used in MySQL to add IF-THEN-ELSE logic to SQL queries? Select all that apply. Answer(s):
IFNULL
IF
(IFNULL is used to return the second value if the first is null, while IF implements IF-THEN-ELSE logic in queries. NULLIF is a logical construct but doesn't directly act as IF logic in query results.)
Question 5:
Type the output value of the following SQL statement with the IFNULL function: SELECT IFNULL (NULL, ‘IFNULL’); Answer: IFNULL
(The IFNULL() function returns the second argument ('IFNULL') since the first argument is NULL.)
Question 6:
True or False: A stored procedure is a prepared SQL code that can be saved and reused by calling the procedure identifier name. Answer: True
(A stored procedure is a precompiled collection of SQL statements that can be invoked using its identifier.)
Question 7:
The following SQL statement creates a procedure that returns all names from the Clients table. Write the missing keyword to create the procedure: CREATE _______ GetClientsNames() SELECT names FROM Clients; Answer: PROCEDURE
(The keyword PROCEDURE is used to define a stored procedure in MySQL.)
Question 8:
How many parameters can you use in a MySQL stored procedure? Select all that apply. Answer(s):
Zero
One
Many
(A MySQL stored procedure can take zero, one, or many parameters depending on how it's defined.)
Question 9:
Select the correct option to invoke a stored procedure: Answer: CALL procedure_name();
(To execute a stored procedure in MySQL, use the CALL command followed by the procedure name, with parentheses for passing parameters if required.)
Question 10:
What is the output of the following stored procedure when the number 5 is passed as an argument to the xNumber parameter?
Answer: 1
(The % operator returns the remainder when xNumber (5) is divided by 2. Since 5 % 2 = 1, the output is 1.)
Enter answer here
1 point
3.
Question 3
True or False: You must use the SELF JOIN clause to perform a SELF JOIN.
True
False
1 point
4.
Question 4
The following SQL statement adds an "Email" column to the "Students" table. Write the missing command name.
1
ALTER TABLE Students __________ Email VARCHAR (255);
Enter answer here
1 point
5.
Question 5
Which type of join returns only matching records from the left table and the right table?
LEFT JOIN
INNER JOIN
RIGHT JOIN
1 point
6.
Question 6
The following query includes a subquery that returns the ID of the player with the highest score in the Games table.
1
SELECT ID FROM Games WHERE score = (SELECT MAX (score) FROM Games);
What type of query is the (SELECT MAX (score) FROM Games)?
Inner query
Outer query
1 point
7.
Question 7
Write the missing function name that tests whether an expression is NULL.
1
SELECT ________(NULL);
Enter answer here
1 point
8.
Question 8
When executed, the following SQL statement prints the IDs of customers who made more than 5 orders. Type the missing keyword to filter the grouped data.
SELECT CustomerID FROM Orders GROUP BY CustomerID _______ COUNT (CustomerID) > 5;
Anything else
HAVING
1 point
9.
Question 9
Which of the following operators means that the condition will be true only if the operation is true for all values in the range?
ANY
ALL
1 point
10.
Question 10
Write the SQL command name to invoke the following stored procedure.
1
______________ HelpMe();
Enter answer here
1 point
Here are the answers to your questions:
Question 1:
The manager of ‘Little Lemon’ restaurant needs to view all bookings from 2021-10-10 to 2021-10-20. Which SQL statements can be used? Select all that apply. Answer(s):
SELECT * FROM Orders WHERE BookingDate > '2021-10-10' AND BookingDate < '2021-10-20';
SELECT * FROM Bookings WHERE BookingDate BETWEEN '2021-10-10' AND '2021-10-20';
SELECT * FROM Orders WHERE BookingDate >= '2021-10-10' AND BookingDate <= '2021-10-20';
(All these valid queries can achieve the task while handling inclusive/exclusive date conditions.)
Question 2:
A join in a database joins records of data between one or multiple tables based on a _______________ column. Answer: common
(A join operates on a common column shared between tables.)
Question 3:
True or False: You must use the SELF JOIN clause to perform a SELF JOIN. Answer: False
(MySQL does not have an explicit SELF JOIN clause. You can achieve a self-join by aliasing the same table.)
Question 4:
The following SQL statement adds an "Email" column to the "Students" table. Write the missing command name: ALTER TABLE Students __________ Email VARCHAR (255); Answer: ADD
(The ADD keyword is used to add a new column to a table using ALTER TABLE.)
Question 5:
Which type of join returns only matching records from the left table and the right table? Answer: INNER JOIN
(The INNER JOIN returns records that have matching values in both tables.)
Question 6:
The query includes a subquery: SELECT ID FROM Games WHERE score = (SELECT MAX(score) FROM Games);
What type of query is (SELECT MAX(score) FROM Games)? Answer: Inner query
(The subquery enclosed in parentheses is called an inner query.)
Question 7:
Write the missing function name that tests whether an expression is NULL: SELECT ________(NULL); Answer: ISNULL
(The ISNULL function tests if a given expression or value is NULL.)
Question 8:
When executed, the SQL statement prints the IDs of customers who made more than 5 orders. Type the missing keyword: SELECT CustomerID FROM Orders GROUP BY CustomerID ________ COUNT(CustomerID) > 5; Answer: HAVING
(The HAVING clause is used to filter grouped data after an aggregate function, such as COUNT.)
Question 9:
Which of the following operators means that the condition will be true only if the operation is true for all values in the range? Answer: ALL
(The ALL operator ensures that a condition is true for all values in the range.)
Question 10:
Write the SQL command name to invoke the following stored procedure: ______________ HelpMe(); Answer: CALL
(The CALL command is used to invoke a stored procedure in MySQL.)
1
________ GetProductDetails();
Enter answer here
1 point
3.
Question 3
Which of the following statements is true of MySQL functions? Select all that apply.
A function can only have output parameters.
A function always returns a value.
A function can only have input parameters.
A function can have both input and output parameters.
1 point
4.
Question 4
What’s the correct syntax to create a user-defined variable in MySQL?
var variable_name = value;
@variable_name = value;
variable_name = value;
1 point
5.
Question 5
What does the DETERMINISTIC keyword do in the following syntax?
123
CREATE FUNCTION function_name()
RETURNS datatype DETERMINISTIC
RETURN
It makes sure that the function returns different results for the same input parameters.
It makes sure that the function returns different results for different input parameters.
It makes sure that the function always returns the same result for the same input parameters.
1 point
6.
Question 6
What type of parameter is the following syntax an example of?
1
SET @y_number = 10;
INOUT parameter
OUT parameter
IN parameter
1 point
7.
Question 7
Which of the following events or SQL operations can MySQL triggers be invoked on? Select all that apply.
DELETE
CREATE
SELECT
INSERT
UPDATE
1 point
8.
Question 8
You need to impose a business rule that checks values before they’re added to a table. What type of trigger can you use to implement this rule?
AFTER UPDATE
AFTER INSERT
BEFORE UPDATE
BEFORE INSERT
1 point
9.
Question 9
Which of the following options are examples of Scheduled Events that can be created in MySQL? Select all that apply.
UPDATE events
One-time events
INSERT events
DELETE events
Recurring events
1 point
10.
Question 10
You are creating an event in MySQL using the following syntax. However, MySQL should only create the event if it doesn't already exist in the database. What keyword can you use to complete this syntax?
1234
CREATE EVENT _______________ event_name
ON SCHEDULE schedule_logic
DO
Event_body
Enter answer here
1 point
Here are the answers to your questions:
Question 1:
You can use MySQL stored procedures and functions to call a block of code to perform a specific operation by invoking the identifier name. Answer: True
(MySQL stored procedures and functions allow you to reuse a block of code, and they can be invoked using the procedure/function name.)
Question 2:
Your MySQL database contains a stored procedure called GetProductDetails(). What keyword can you use to invoke this stored procedure? Answer: CALL
(To invoke a stored procedure, use the CALL keyword: CALL GetProductDetails();.)
Question 3:
Which of the following statements is true of MySQL functions? Select all that apply. Answer(s):
A function always returns a value.
A function can only have input parameters.
(MySQL functions must always return a value, and they only accept input parameters.)
Question 4:
What’s the correct syntax to create a user-defined variable in MySQL? Answer: @variable_name = value;
(In MySQL, user-defined variables start with @ and are assigned with the syntax @variable_name = value;.)
Question 5:
What does the DETERMINISTIC keyword do in the following syntax?
CREATE FUNCTION function_name()
RETURNS datatype DETERMINISTIC
RETURN ...
Answer: It makes sure that the function always returns the same result for the same input parameters.
(The DETERMINISTIC keyword declares that the function produces the same output when given the same input values.)
Question 6:
What type of parameter is the following syntax an example of?
SET @y_number = 10;
Answer: IN parameter
(The variable @y_number is an example of an input (IN) parameter that can be passed into stored procedures.)
Question 7:
Which of the following events or SQL operations can MySQL triggers be invoked on? Select all that apply. Answer(s):
DELETE
INSERT
UPDATE
(MySQL triggers operate on DML (Data Manipulation Language) operations like INSERT, DELETE, and UPDATE.)
Question 8:
You need to impose a business rule that checks values before they’re added to a table. What type of trigger can you use to implement this rule? Answer: BEFORE INSERT
(A BEFORE INSERT trigger runs before new data is inserted into a table, allowing you to enforce business rules.)
Question 9:
Which of the following options are examples of Scheduled Events that can be created in MySQL? Select all that apply. Answer(s):
One-time events
Recurring events
(Scheduled events in MySQL are based on time and can either run once or at recurring intervals.)
Question 10:
You are creating an event in MySQL using the following syntax. MySQL should only create the event if it doesn’t already exist in the database. What keyword can you use to complete this syntax?
CREATE EVENT _______________ event_name
ON SCHEDULE schedule_logic
DO
Event_body
Answer: IF NOT EXISTS
(The CREATE EVENT IF NOT EXISTS ensures that the event is only created if it doesn't already exist in the database.)
1 point
3.
Question 3
You should always use the FULL OUTER JOIN to optimize the SQL query when you extract data from multiple tables.
True
False
1 point
4.
Question 4
Write the missing keyword to create an Index on the FullName column in the following SQL statement:
1
CREATE _________ IndexFullName ON Clients (FullName);
Enter answer here
1 point
5.
Question 5
Which of the following keywords are used to manage database transactions? Select all that apply.
COMMIT
END
ROLLBACK
START TRANSACTION
1 point
6.
Question 6
A Common Table Expression (CTE) is used to deconstruct complex queries into simple blocks of code to simplify the query and make it easier to read and maintain.
True
False
1 point
7.
Question 7
Write the missing keyword required to create the following Common Table Expression:
1
________ CTE_Name AS (query code) SELECT * FROM CTE_Name;
Enter answer here
1 point
8.
Question 8
A prepared statement in MySQL includes certain unspecified values used as parameters. Which symbol is used to represent the parameters in the prepared statements?
->
:=
=
?
1 point
9.
Question 9
When working with a prepared statement, MySQL only parses a query once no matter how many times its executed.
False
True
1 point
10.
Question 10
Write the operator that you need to use to access the values in the Properties JSON column.
You need to access the JSON values from the Properties column in the Activity table using the following SQL query. What operator is missing from your query?
1
SELECT Properties _____"$.ClientID" FROM Activity;
Enter answer here
1 point
Here are the answers to each question:
Question 1:
In a SELECT statement, the use of functions and wildcards in predicates could hinder the performance of column indexes. Answer: True
(Using functions or wildcards in predicates can prevent indexes from being used efficiently, as it often forces the database to perform a full table scan.)
Question 2:
Which of the following statements apply to MySQL indexes? Select all that apply. Answer(s):
Data stored in the index is always sorted.
An index is a data structure that helps maintain pointers to data in a table.
(Index helps in sorting, searching, and maintaining data pointers. Indexes do not have to be limited to one column, and primary indexes are created automatically, while secondary indexes are created programmatically.)
Question 3:
You should always use the FULL OUTER JOIN to optimize the SQL query when you extract data from multiple tables. Answer: False
(FULL OUTER JOINs include all rows from both tables, even when there's no match, which can result in inefficient queries depending on use cases. It's only used when you explicitly need unmatched rows.)
Question 4:
Write the missing keyword to create an Index on the FullName column in the following SQL statement:
CREATE _________ IndexFullName ON Clients (FullName);
Answer: INDEX
(The correct keyword to create an index in MySQL is INDEX: CREATE INDEX IndexFullName ON Clients (FullName);)
Question 5:
Which of the following keywords are used to manage database transactions? Select all that apply. Answer(s):
COMMIT
ROLLBACK
START TRANSACTION
(These keywords are standard tools for managing transactions. END is not a keyword used for transactional operations.)
Question 6:
A Common Table Expression (CTE) is used to deconstruct complex queries into simple blocks of code to simplify the query and make it easier to read and maintain. Answer: True
(CTEs allow for more readable code by breaking down complex queries into reusable and simplified logical blocks.)
Question 7:
Write the missing keyword required to create the following Common Table Expression:
________ CTE_Name AS (query code) SELECT * FROM CTE_Name;
Answer: WITH
(A Common Table Expression (CTE) starts with the WITH keyword:
WITH CTE_Name AS (query code) SELECT * FROM CTE_Name;
```)
---
### **Question 8:**
A prepared statement in MySQL includes certain unspecified values used as parameters. Which symbol is used to represent the parameters in prepared statements?
**Answer**: **?**
(The `?` symbol is used as a placeholder for parameters in prepared statements.)
---
### **Question 9:**
When working with a prepared statement, MySQL only parses a query once no matter how many times it's executed.
**Answer**: **True**
(MySQL parses a prepared statement once, and it can then reuse the compiled statement multiple times, enhancing performance.)
---
### **Question 10:**
Write the operator that you need to use to access the values in the `Properties` JSON column:
```sql
SELECT Properties _____ "$.ClientID" FROM Activity;
Answer: ->
(The -> operator is used to access JSON values in MySQL. The query should look like:
SELECT Properties -> "$.ClientID" FROM Activity;
```)
---
Predictive data analysis
Descriptive data analysis
Inferential data analysis
Causal data analysis
1 point
4.
Question 4
One of the key limitations that database engineers encounter when using MySQL for data analytics is that it doesn’t provide tools for data visualization.
True
False
1 point
5.
Question 5
Which of the following methods can be used to perform a critical data analysis in MySQL? Select all that apply.
Virtual table
Stored Procedures
JOIN
JSON data type
Subquery
1 point
6.
Question 6
You need to extract data from multiple tables in MySQL. What type of JOIN do you need to emulate to carry out this task?
FULL OUTER JOIN
INNER JOIN
RIGHT JOIN
LEFT JOIN
1 point
7.
Question 7
You need to combine a set of results from multiple SELECT statements. What operator can you use to complete this action?
Enter answer here
1 point
8.
Question 8
The following FindCost function returns the total cost of a product sold in 2022 based on the user input of the product id. Write the missing parameter name to pass the product id value to the FindCost function.
1
CREATE FUNCTION FindCost(_____________ VARCHAR(10)) returns DECIMAL(10,2) DETERMINISTIC RETURN (SELECT SUM(Cost) FROM Orders WHERE ProductID = product_id);
Enter answer here
1 point
9.
Question 9
You are querying two tables in a database. You need to return all matching results from the left table, with the NULL results from the right table. What type of JOIN can you use to carry out this query?
______________ JOIN.
Enter answer here
1 point
10.
Question 10
You are creating a query that requires more than one SELECT statement. One of these statements must also provide a subset of the table. Type the name of the query that you can use to complete this task: ________
Enter answer here
1 point
Here are the answers to each question:
Question 1:
The relational database model in MySQL makes it easy for users to access, retrieve, and analyze data in MySQL. Answer: True
(Relational database models, including MySQL, are designed for efficient data access, retrieval, and analysis.)
Question 2:
Which type of data analysis is used to investigate data and identify relationships between different variables in the database? Answer: Exploratory data analysis
(Exploratory data analysis focuses on investigating and understanding relationships within the data.)
Question 3:
Which type of data analysis uses existing data to find paradigms and patterns to make predictions about an organization’s performance and progress? Answer: Predictive data analysis
(Predictive data analysis uses historical data and patterns to make predictions about future performance.)
Question 4:
One of the key limitations that database engineers encounter when using MySQL for data analytics is that it doesn’t provide tools for data visualization. Answer: True
(MySQL itself does not include built-in tools for data visualization. External tools like Tableau or Power BI are required for visualization.)
Question 5:
Which of the following methods can be used to perform critical data analysis in MySQL? Select all that apply. Answer(s):
Virtual table
Stored Procedures
JOIN
Subquery
(The JSON data type is useful for storing data but is not a key method for performing data analysis.)
Question 6:
You need to extract data from multiple tables in MySQL. What type of JOIN do you need to emulate to carry out this task? Answer: INNER JOIN
(INNER JOIN is used to extract matching data from multiple tables. If all matching results are needed, including NULLs, other JOINs like LEFT JOIN or RIGHT JOIN might be used.)
Question 7:
You need to combine a set of results from multiple SELECT statements. What operator can you use to complete this action? Answer: UNION
(The UNION operator is used to combine the results of two or more SELECT statements into a single result set.)
Question 8:
The following FindCost function calculates the total cost of a product sold in 2022 based on the user input for the product ID. What parameter name should you use?
CREATE FUNCTION FindCost(_____________ VARCHAR(10))
RETURNS DECIMAL(10,2)
DETERMINISTIC
RETURN (SELECT SUM(Cost) FROM Orders WHERE ProductID = product_id);
Answer: product_id
(The parameter name product_id matches the usage inside the function.)
Question 9:
You are querying two tables in a database and need to return all matching results from the left table with NULL results from the right table. What type of JOIN can you use? Answer: LEFT JOIN
(A LEFT JOIN returns all records from the left table and fills NULLs where there are no matches from the right table.)
Question 10:
You are creating a query that requires more than one SELECT statement, with one of these statements providing a subset of the table. What is the query type? Answer: Subquery
(A Subquery is a query nested within another query and is used to provide subsets of data for further operations.)
Change the default delimiter.
Use the CREATE PROCEDURE command.
1 point
2.
Question 2
Which of the following parameters are accepted by MySQL stored procedures? Select all that apply.
INOUT
IN
OUT
1 point
3.
Question 3
Write the missing command name required to create the UpdateAudit trigger in the following SQL statement:
12345
CREATE ____________ UpdateAudit
AFTER INSERT ON Orders
FOR EACH ROW
INSERT INTO Audit (OrderDateTime)
VALUES (Current_timestamp);
Enter answer here
1 point
4.
Question 4
Indexes help to optimize SELECT statements in MySQL because they can be used to quickly look up data in the database.
True
False
1 point
5.
Question 5
Which of the following commands can you use to initiate a transaction in MySQL? Select all that apply.
TRIGGER
BEGIN
START TRANSACTION
BEGIN WORK
1 point
6.
Question 6
You need to roll back your current transaction and cancel the changes made to the database in MySQL. Write the name of the command that you can use to complete this task.
Enter answer here
1 point
7.
Question 7
Write the name of the clause required to start a common table expression (CTE) in MySQL.
Enter answer here
1 point
8.
Question 8
The following Activity table uses the JSON data type to log information about the activities of clients.
Screenshot of Activity table
Which of the following statements can be used to access the ClientID values in the table’s Properties column?
SELECT Properties :='$.ClientID' FROM Activity;
SELECT Properties >'$.ClientID' FROM Activity;
SELECT Properties =>'$.ClientID' FROM Activity;
SELECT Properties->'$.ClientID' FROM Activity;
1 point
9.
Question 9
The FULL OUTER JOIN is not supported in MySQL, but you can emulate it using a combination of LEFT and RIGHT JOIN statements.
True
False
1 point
10.
Question 10
The following LogActivity trigger must be invoked automatically after the insertion of each new order in the Orders table. Write the missing keyword required to create this trigger.
12345
CREATE TRIGGER LogActivity ________
INSERT ON Orders
FOR EACH ROW
INSERT INTO Audit (OrderDateTime)
VALUES (Current_timestamp);
Enter answer here
1 point
Here are the complete answers to your questions:
Question 1:
You need to create a stored procedure that contains multiple statements. Which of the following steps can you take to complete this task? Select all that apply. Answer(s):
Define the procedure’s body using the BEGIN END keywords.
Change the default delimiter.
Use the CREATE PROCEDURE command.
(Stored procedures can contain multiple statements, and they need to be enclosed between BEGIN and END. Changing the delimiter is necessary to distinguish procedure elements from standard SQL commands.)
Question 2:
Which of the following parameters are accepted by MySQL stored procedures? Select all that apply. Answer(s):
IN
OUT
INOUT
(MySQL supports all three parameter types—IN (for passing input values), OUT (for returning output values), and INOUT (for both input and output values).)
Question 3:
Write the missing command name required to create the UpdateAudit trigger in the following SQL statement:
CREATE ____________ UpdateAudit
AFTER INSERT ON Orders
FOR EACH ROW
INSERT INTO Audit (OrderDateTime)
VALUES (Current_timestamp);
Answer: TRIGGER
(The TRIGGER keyword is used to create triggers. The complete statement is:
CREATE TRIGGER UpdateAudit
AFTER INSERT ON Orders
FOR EACH ROW
INSERT INTO Audit (OrderDateTime)
VALUES (Current_timestamp);
```)
---
### **Question 4:**
Indexes help to optimize SELECT statements in MySQL because they can be used to quickly look up data in the database.
**Answer**: **True**
(Indexes are data structures that reduce lookup time and optimize `SELECT` statement performance.)
---
### **Question 5:**
Which of the following commands can you use to initiate a transaction in MySQL? Select all that apply.
**Answer(s):**
- **BEGIN**
- **START TRANSACTION**
- **BEGIN WORK**
(These commands are used to begin a transaction in MySQL. `TRIGGER` is not used for transactions.)
---
### **Question 6:**
You need to roll back your current transaction and cancel the changes made to the database in MySQL. Write the name of the command that you can use to complete this task.
**Answer**: **ROLLBACK**
(The `ROLLBACK` command is used to undo the changes made during a transaction and cancel it.)
---
### **Question 7:**
Write the name of the clause required to start a common table expression (CTE) in MySQL.
**Answer**: **WITH**
(The `WITH` clause is used to start a CTE in MySQL, e.g.:
```sql
WITH CTE_Name AS (query code)
SELECT * FROM CTE_Name;
```)
---
### **Question 8:**
The following Activity table uses the JSON data type to log information about the activities of clients.
Which of the following statements can be used to access the `ClientID` values in the table’s `Properties` column?
**Answer**:
- **`SELECT Properties->'$.ClientID' FROM Activity;`**
(The `->` operator is used to extract JSON values in MySQL.)
---
### **Question 9:**
The FULL OUTER JOIN is not supported in MySQL, but you can emulate it using a combination of LEFT and RIGHT JOIN statements.
**Answer**: **True**
(MySQL does not directly support `FULL OUTER JOIN`. However, it can be emulated by combining `LEFT JOIN` and `RIGHT JOIN` with a `UNION`.)
---
### **Question 10:**
The following `LogActivity` trigger must be invoked automatically after the insertion of each new order in the Orders table. Write the missing keyword required to create this trigger:
```sql
CREATE TRIGGER LogActivity ________
INSERT ON Orders
FOR EACH ROW
INSERT INTO Audit (OrderDateTime)
VALUES (Current_timestamp);
Answer: AFTER
(The missing keyword is AFTER, as triggers are defined by their timing (AFTER INSERT, BEFORE UPDATE, etc.). The full statement is:
CREATE TRIGGER LogActivity AFTER
INSERT ON Orders
FOR EACH ROW
INSERT INTO Audit (OrderDateTime)
VALUES (Current_timestamp);
```)
---