Exam: DP-900: Microsoft Azure Data Fundamentals 0 Likes
You have a SQL query that combines customer data and order data. The (DP-900)
You have a SQL query that combines customer data and order data. The query includes calculated columns.
You need to create a database object that would allow other users to rerun the same SQL query.
What should you create?
A. an index
B. a view
C. a scalar function
D. a table
Solution
Correct answer: B. a view.
A view is a database object that represents the result of a SQL query. It acts as a virtual table, allowing other users to access the same data and calculations as the original query.
In the given scenario, you have a SQL query that combines customer data and order data, including calculated columns. To allow other users to rerun the same SQL query, creating a view would be the appropriate solution.
Here's why the other options are not the correct answers:
A. An index is used to improve the performance of queries by creating a data structure that allows faster searching and retrieval of data. It is not the right choice for reusing a complex SQL query.
C. A scalar function is a user-defined function that returns a single value. It is not suitable for encapsulating a complex SQL query that returns a result set.
D. Creating a table would require you to materialize the data from the original query, which may not be the most efficient solution, especially if the data is frequently updated or the query is complex.
By creating a view, you can encapsulate the SQL query and make it available to other users, allowing them to access the same data and calculations without having to recreate the original query.
Category: Core Data Concepts