Querying and Filtering Data

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/64

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

65 Terms

1
New cards

What is often the first task a data analyst performs when working with data?

Querying the data for the required information

2
New cards

What tools might a data analyst use to query data?

SQL or graphical data tools like SQL Server Management Studio, Tableau

3
New cards

Why might a report with only unique identifiers, like product IDs, be difficult to understand?

It lacks detailed information about the products making it less informative

4
New cards

In the example of a sales database, why would a report with just product IDs be insufficient?

It lacks the full product name which is necessary for understanding sales

5
New cards

What does a data analyst need to do to make a report with product IDs more useful?

Join the product ID with a separate product table to pull the product name

6
New cards

What is an example of a real-world application of joining tables?

Joining payments and customer tables to get customer names for a report

7
New cards

What is the purpose of using a join command in a query?

To merge data from multiple tables into one unified report.

8
New cards

What is one key challenge when creating queries?

Making the output human-readable and understandable  

9
New cards

How are payments and customers tables related?

The customer number in payments and customer table can be linked

10
New cards

Why might there be complexity in performing a join in SQL?

There are various ways to construct joins and manage table relationships

11
New cards

Which type of join is the most commonly used in data analysis?

Inner join

12
New cards

What does an inner join return?

Only the rows where a matching field exists between two tables

13
New cards

In the left outer join, which data is included in the result set?

All data from the left table, and matching data from the right table

14
New cards

What is the difference between a left outer join and a right outer join?

Includes all left data; includes all right data

15
New cards

What does a full outer join return?

All rows from both tables, whether they match or not

16
New cards

What is the result of performing a cross join between two tables?

The cartesian product of both tables combining each record from both tables

17
New cards

What is a potential risk of performing a cross join?

It can result in a very large number of rows in the output

18
New cards

When is a full outer join most useful?

When you need to return all data from both tables, regardless of matches

19
New cards

What does a left outer join return when there is no matching data in the right table?

Only rows from left table are returned with nulls for missing right data

20
New cards

Which of the following is true about using inner joins in SQL queries?

Inner joins return only where a specific field matches in both tables

21
New cards

What is the primary purpose of filtering data in SQL?

To restrict the query to a subset of the source data

22
New cards

Which SQL clause is commonly used to filter data?

WHERE

23
New cards

Why is filtering data important for query performance optimization?

It reduces the data set early, improving subsequent query efficiency

24
New cards

What is an example of using a WHERE clause to filter data?

ALL OF THE ABOVE 

25
New cards

What does filtering data early in a query help with in large data warehouses?

It reduces the resources required and speeds up query execution

26
New cards

What does the WHERE clause WHERE state = ‘CA’ do?

Filter data to show customers from California only

27
New cards

When constructing a query, what might be the first step to improve performance?

Filtering the data to include only the necessary records

28
New cards

Which of the following is NOT a benefit of filtering data in SQL? 

Increases the amount of data retrieved

29
New cards

What is the main purpose of parameterization in SQL queries?

to reuse queries with different values for filter

30
New cards

How do parameters work in SQL queries?

The parameter is entered externally and inserted into the query

31
New cards

In which scenario would parameterization be most useful?

When executing the same query with different filter values

32
New cards

How is a parameter typically defined in a SQL query?

It is set using a variable, such as set @state = ‘MA’

33
New cards

What tool allows you to use parameters in a graphical interface?

Tableau

34
New cards

How does parameterization make it easier to generate different reports?

It allows the user to enter different filter values to get different result

35
New cards

What is the benefit of using parameterization in SQL queries?

It simplifies executing the same query with different parameters

36
New cards

How would you modify a query to filter by a different state in a parameterized query?

Change the value o the parameter (e.g. set @state = ‘New State’)

37
New cards

What is one advantage of using parameterization when building applications that use SQL queries?

It allows the user to easily input different filter values

38
New cards

What is the main purpose of an index in a database table?

To speed up queries on a given column

39
New cards

When would you create an index on a column in a database?

When the column is frequently used in filtering or querying

40
New cards

What happens if you do not use an index on a frequently queried column?

The database will have to scan through every record to find matches

41
New cards

Which of the following is indexed automatically by the database?

Primary keys

42
New cards

What is one potential downside of using indexes in a database?

They increase the time and space required to add or update records.

43
New cards

What is an example of when an explicit index might be created in a table?

To speed up queries filtering on a field like sales rep employee number

44
New cards

Which of the following is NOT a cost of using indexes in a database?

They can slow down queries on columns that are indexed

45
New cards

Why would you create an index on a column that is not a key in the table?

To speed up queries that filter on that column

46
New cards

What happens when an index is created on a column that is frequently updated?

The index must be updated manually whenever a record is added or updated

47
New cards

What is a trade-off when deciding to create an index on a column?

Increased query speed but at the cost of additional storage and maintenance.

48
New cards

What is the primary purpose of filtering data before executing complex queries?

To reduce the amount of data being processed, improving the query performance.

49
New cards

What happens to a temporary table when you disconnect from the database?

It is deleted as it only exists within the session.

50
New cards

How do you create a temporary table in SQL?

CREATE TEMPORARY TABLE table_name AS SELECT

51
New cards

Which of the following is an advantage of using temporary tables?

Allows queries to be executed on smaller subset of data improving efficiency.

52
New cards

Why might breaking down complex queries into multiple temporary tables be beneficial.

It makes queries easier to understand and debug.

53
New cards

What is another term for a nested query?

Subquery

54
New cards

What is the primary purpose of a subquery?

To simplify complex queries by operating on a subset of data.

55
New cards

How should you typically approach understanding a nested query?

From the inner query to the outer query.

56
New cards

What does the inner query “SELECT AVG(buyPrice) FROM products” calculate?

The average buy price.

57
New cards

What is the goal of example query “SELECT * FROM products WHERE buyPrice > (SELECT AVG(buyPrice) FROM products)”?

To select all products with a buy price greater than the average.

58
New cards

Which of the following is considered as a challenge with complex subqueries?

Optimizing performance and understanding execution efficiency.

59
New cards

What is the main difference between using a subquery and a temporary table to achieve a similar result?

Nest queries within a single command; break the operation into multiple steps.

60
New cards

What is the primary purpose of a Query Execution Plan?

To visualize the order in which a query is executed.

61
New cards

What is another common name for a Query Execution Plan?

Explain Plan

62
New cards

What SQL command is often used to generate a Query Execution Plan

EXPLAIN

63
New cards

What potential performance issue in a query execution plan?

Multiple full table scans

64
New cards

What is a potential strategy to improve query performance?

Executing filtering operations earlier in the query.

65
New cards

Who is typically best suited to optimize complex database queries?

Database Specialists