SQL Queries Flashcards

1
Q

Which of the following is the correct syntax for referencing an Attribute within an Entity in an SQL Query?

A. {Entity}.[Attribute]
B. (Entity).{Attribute}
C. [Entity].{Attribute}
D. Entity.Attribute

A

A. {Entity}.[Attribute]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the term “SQL dialect” refer to?

A. The specific version of the SQL language used by a particular database system.
B. The way in which SQL code is written in a specific region.
C. The process of converting SQL code into machine-readable instructions.
D. The specific type of data a database can store.

A

A. The specific version of the SQL language used by a particular database system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between an Entity and a Structure in OutSystems?

A. An Entity represents data stored in a database, while a Structure is a data type definition.

B. An Entity is a data type, while a Structure represents a table in the database.

C. Entities can be used to define relationships between tables, while Structures are used for simple data types.

D. Entities can be used in both client-side and server-side logic, while Structures are used only on the server side.

A

A. An Entity represents data stored in a database, while a Structure is a data type definition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of “input parameters” in SQL Queries?

A. To allow dynamic values to be passed into the query at runtime.

B. To define the data types of the columns in the query result.

C. To specify the order in which data is retrieved from the database.

D. To define the tables involved in the query.

A

A. To allow dynamic values to be passed into the query at runtime.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why are curly brackets used for Entities and square brackets for Attributes in SQL Queries within OutSystems?

A. To differentiate between Entities and Attributes.

B. To ensure compatibility with different database systems.

C. To prevent conflicts with reserved keywords in SQL.

D. To facilitate syntax highlighting in the SQL editor.

A

A. To differentiate between Entities and Attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the “LIMIT” keyword in other databases?

A. To specify the maximum number of rows to be retrieved.

B. To order the retrieved data.

C. To filter the retrieved data based on certain criteria.

D. To group the retrieved data.

A

A. To specify the maximum number of rows to be retrieved.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the “TOP” keyword in SQL Server?

A. To specify the maximum number of rows to be retrieved.

B. To order the retrieved data.

C. To filter the retrieved data based on certain criteria.

D. To group the retrieved data.

A

A. To specify the maximum number of rows to be retrieved.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the “Test Inputs” tab in the SQL Tool?

A. To define the values of input parameters for testing the query.

B. To view the results of a previous query execution.

C. To define the data types of the input parameters.

D. To edit the SQL query itself.

A

A. To define the values of input parameters for testing the query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the role of the “Output Entities/Structures” section in the SQL Tool?

A. To define the data structure of the query’s output.

B. To specify the order in which data is retrieved from the database.

C. To define the tables involved in the query.

D. To define the input parameters for the query.

A

A. To define the data structure of the query’s output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a “non-select query” in SQL?

A. A query that performs actions on the data, such as inserting, updating, or deleting records.

B. A query that retrieves data from multiple tables.

C. A query that retrieves a specific subset of data.

D. A query that uses aggregate functions like COUNT or AVG.

A

A. A query that performs actions on the data, such as inserting, updating, or deleting records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the primary benefit of using an Aggregate instead of a SQL Query when retrieving data?

A. Aggregates are generally easier to use and maintain than SQL Queries.

B. Aggregates provide a more efficient way to retrieve data.

C. Aggregates automatically handle joins between entities.

D. Aggregates are required for performing complex data transformations.

A

A. Aggregates are generally easier to use and maintain than SQL Queries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When is it recommended to use an SQL Query instead of an Aggregate?

A. When retrieving a small number of records.

B. When performing complex queries involving sub-queries or joins that cannot be easily defined in an Aggregate.

C. When retrieving data from multiple tables.

D. When using aggregate functions like COUNT or AVG.

A

B. When performing complex queries involving sub-queries or joins that cannot be easily defined in an Aggregate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the first step involved in converting an existing Aggregate to an SQL Query?

A. Copy the Aggregate and paste it into a Data Action.

B. Create a new Data Action and drag the Aggregate into it.

C. Delete the existing Aggregate and drag an SQL into the Data Action.

D. Open the Aggregate and click the “Convert to SQL” button.

A

C. Delete the existing Aggregate and drag an SQL into the Data Action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

After converting an Aggregate to an SQL Query, what changes are typically required?

A. Update the input and output parameters of the SQL Query.

B. Re-wire the user interface to use the SQL Query instead of the Aggregate.

C. Change the data type of the output structure to match the SQL Query’s output.

D. All of the above.

A

D. All of the above.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of a “DELETE” SQL Query?

A. To retrieve data from a database.

B. To update existing data in a database.

C. To remove data from a database.

D. To create new data in a database.

A

C. To remove data from a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of an “INSERT” SQL Query?

A. To retrieve data from a database.

B. To modify existing data in a database.

C. To remove data from a database.

D. To add new data into a database.

A

D. To add new data into a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of an “UPDATE” SQL Query?

A. To retrieve data from a database.

B. To modify existing data in a database.

C. To remove data from a database.

D. To create new data in a database.

A

B. To modify existing data in a database.

16
Q

What is the role of the “WHERE” clause in an SQL Query?

A. To filter the data retrieved by the query.

B. To specify the order in which data is retrieved.

C. To define the tables involved in the query.

D. To define the columns to be retrieved.

A

A. To filter the data retrieved by the query.

17
Q

How can you set the values for Query Parameters when testing an SQL Query?

A. In the “Test Inputs” tab of the SQL Tool.

B. In the “Output Entities/Structures” section of the SQL Tool.

C. In the “Parameters” folder of the SQL Editor.

D. In the “SQL” tab of the SQL Editor.

A

A. In the “Test Inputs” tab of the SQL Tool.

18
Q

Which SQL statement allows you to retrieve only the first 10 records from a table?

A. SELECT TOP 10 …

B. SELECT LIMIT 10 …

C. SELECT WHERE ROWNUM <= 10 …

D. SELECT * FROM … ORDER BY … LIMIT 10 …

A

A. SELECT TOP 10 …

18
Q

What is the significance of the “TrueChange” error in OutSystems?

A. It indicates that the query has not been executed successfully.

B. It indicates that the database connection is not established properly.

C. It indicates that the input parameters have not been set correctly.

D. It indicates that the output structure does not match the query’s output.

A

C. It indicates that the input parameters have not been set correctly.

19
Q

How would you update the “Price” attribute of all Products with a “Name” that starts with “T”?

A. UPDATE Products SET Price = [Price] * 1.1 WHERE Name LIKE ‘T%’;

B. UPDATE Products SET Price = 100 WHERE Name = ‘T’;

C. UPDATE Products SET Price = 100 WHERE Name LIKE ‘T%’;

D. UPDATE Products SET Price = [Price] * 1.1 WHERE Name = ‘T’;

A

A. UPDATE Products SET Price = [Price] * 1.1 WHERE Name LIKE ‘T%’;

20
Q

How would you delete all records from a table named “Employees”?

A. DELETE Employees;

B. DELETE * FROM Employees;

C. DELETE FROM Employees WHERE [Id] = [Id];

D. DELETE FROM Employees WHERE [Id] > 0;

A

A. DELETE Employees;

20
Q

How would you create a new record in a table named “Customers” with a specific set of data?

A. INSERT INTO Customers (FirstName, LastName) VALUES (‘John’, ‘Doe’);

B. CREATE TABLE Customers (FirstName, LastName) VALUES (‘John’, ‘Doe’);

C. UPDATE Customers SET FirstName = ‘John’, LastName = ‘Doe’;

D. INSERT INTO Customers VALUES (‘John’, ‘Doe’);

A

A. INSERT INTO Customers (FirstName, LastName) VALUES (‘John’, ‘Doe’);

21
Q

What is the purpose of the “JOIN” clause in an SQL Query?

A. To combine data from multiple tables based on a shared column.

B. To filter data from a single table.

C. To group data from a single table.

D. To order data retrieved from a table.

A

A. To combine data from multiple tables based on a shared column.

22
Q

What is the difference between an “INNER JOIN” and a “LEFT JOIN” in SQL?

A. An INNER JOIN only retrieves records that have matches in both tables, while a LEFT JOIN retrieves all records from the left table, even if there’s no match in the right table.

B. An INNER JOIN retrieves all records from the left table, even if there’s no match in the right table, while a LEFT JOIN only retrieves records that have matches in both tables.

C. An INNER JOIN is used for joining two tables with a one-to-one relationship, while a LEFT JOIN is used for joining tables with a one-to-many relationship.

D. An INNER JOIN retrieves all records from the right table, even if there’s no match in the left table, while a LEFT JOIN only retrieves records that have matches in both tables.

A

A. An INNER JOIN only retrieves records that have matches in both tables, while a LEFT JOIN retrieves all records from the left table, even if there’s no match in the right table.

22
Q

How would you retrieve all Employees with a “Salary” greater than 50000, sorted by “LastName” in ascending order?

A. SELECT * FROM Employees WHERE Salary > 50000 ORDER BY LastName ASC;

B. SELECT * FROM Employees WHERE Salary > 50000 ORDER BY FirstName ASC;

C. SELECT * FROM Employees WHERE Salary < 50000 ORDER BY LastName ASC;

D. SELECT * FROM Employees WHERE Salary > 50000 ORDER BY Salary ASC

A

A. SELECT * FROM Employees WHERE Salary > 50000 ORDER BY LastName ASC;

23
Q

How would you count the number of records in a table named “Orders”?

A. SELECT COUNT(*) FROM Orders;

B. COUNT Orders;

C. SELECT COUNT(Orders) FROM Orders;

D. COUNT(*) FROM Orders;

A

A. SELECT COUNT(*) FROM Orders;

23
Q

What is the purpose of the “ORDER BY” clause in an SQL Query?

A. To sort the retrieved data based on a specific column.

B. To filter the retrieved data based on a specific criteria.

C. To group the retrieved data based on a specific column.

D. To define the columns to be retrieved.

A

A. To sort the retrieved data based on a specific column.

24
Q

How would you calculate the average “Price” of all products in a table named “Products”?

A. SELECT AVG(Price) FROM Products;

B. AVG(Price) FROM Products;

C. SELECT AVG(Products) FROM Products;

D. SELECT AVG(Products) FROM Price;

A

A. SELECT AVG(Price) FROM Products;

25
Q

What are sub-queries in SQL?

A. Sub-queries are queries nested within another query.

B. Sub-queries are used to retrieve data from multiple tables.

C. Sub-queries are used to filter data based on a specific condition.

D. Sub-queries are used to group data based on a specific column.

A

A. Sub-queries are queries nested within another query.

26
Q

How are sub-queries used in conjunction with other clauses in SQL?

A. Sub-queries can be used in the WHERE, HAVING, and SELECT clauses to filter, filter grouped data, and return data based on a conditional result, respectively.

B. Sub-queries can be used in the JOIN, ORDER BY, and GROUP BY clauses to join tables, sort data, and group data, respectively.

C. Sub-queries can only be used in the WHERE clause to filter data.

D. Sub-queries can be used in any clause of an SQL query.

A

A. Sub-queries can be used in the WHERE, HAVING, and SELECT clauses to filter, filter grouped data, and return data based on a conditional result, respectively.

27
Q

What is the purpose of the “UNION” operator in SQL?

A. To combine the results of two or more queries, eliminating duplicate rows.

B. To join two or more tables based on a common column.

C. To filter data based on a specific condition.

D. To group data based on a specific column.

A

A. To combine the results of two or more queries, eliminating duplicate rows.

28
Q

How can you ensure that the results of a “UNION” operation are distinct (no duplicates)?

A. Use the “UNION ALL” operator.

B. Use the “DISTINCT” keyword in the SELECT clause.

C. Use the “GROUP BY” clause in the SELECT clause.

D. Use the “ORDER BY” clause in the SELECT clause.

A

B. Use the “DISTINCT” keyword in the SELECT clause.

29
Q

What is the purpose of a “VIEW” in SQL?

A. A virtual table that represents a pre-defined query.

B. A physical table that stores data from multiple tables.

C. A temporary table that stores data for a specific session.

D. A stored procedure that executes a set of SQL statements.

A

A. A virtual table that represents a pre-defined query.

30
Q

What are “stored procedures” in SQL?

A. Pre-compiled SQL code that can be executed by name.

B. Virtual tables that represent a pre-defined query.

C. Physical tables that store data from multiple tables.

D. Temporary tables that store data for a specific session.

A

A. Pre-compiled SQL code that can be executed by name.

31
Q

What is the purpose of “transactions” in SQL?

A. To ensure data integrity by grouping multiple SQL statements into a single unit of work that either succeeds or fails as a whole.

B. To provide security by controlling access to database objects.

C. To optimize query performance by caching frequently used data.

D. To manage concurrency by allowing multiple users to access the database simultaneously.

A

A. To ensure data integrity by grouping multiple SQL statements into a single unit of work that either succeeds or fails as a whole.

32
Q

What is the purpose of “indexes” in SQL databases?

A. To speed up data retrieval by creating a sorted index on a specific column or set of columns.

B. To improve data security by encrypting sensitive information.

C. To manage concurrency by allowing multiple users to access the database simultaneously.

D. To enforce data integrity by ensuring data consistency across different tables.

A

A. To speed up data retrieval by creating a sorted index on a specific column or set of columns.

32
Q

What is the purpose of the “COMMIT” and “ROLLBACK” commands in SQL transactions?

A. “COMMIT” permanently saves changes made within a transaction, while “ROLLBACK” undoes those changes.

B. “COMMIT” undoes changes made within a transaction, while “ROLLBACK” permanently saves those changes.

C. “COMMIT” starts a new transaction, while “ROLLBACK” ends the current transaction.

D. “COMMIT” and “ROLLBACK” are used to define the scope of a transaction.

A

A. “COMMIT” permanently saves changes made within a transaction, while “ROLLBACK” undoes those changes.

33
Q

How can indexes improve query performance?

A. Indexes allow the database to quickly locate data based on the indexed column, rather than scanning the entire table.

B. Indexes compress data, reducing the amount of data that needs to be scanned.

C. Indexes create copies of data, allowing faster access to frequently used information.

D. Indexes automatically optimize queries by identifying the best execution plan.

A

A. Indexes allow the database to quickly locate data based on the indexed column, rather than scanning the entire table.