CompTIA DataSys+ (DS0-001)Database FundamentalsMedium

A data analytics team frequently needs to view a combined dataset of `CustomerName`, `ProductName`, and `OrderDate` from multiple joined tables (`Customers`, `Products`, `Orders`, `OrderDetails`). To simplify their queries and enforce consistent data access, which database object should the database administrator create?

  1. AA database trigger
  2. BA stored procedure
  3. CA database view
  4. DA materialized view
Show answer & explanation

Correct answer: C. A database view

A database view is a virtual table based on the result-set of a SQL query. It simplifies complex queries by presenting a predefined subset or combination of data from one or more tables as if it were a single table.

Why the other options are wrong

  • A. A database trigger is a special type of stored procedure that executes automatically when an event occurs on a database table, which is not for simplifying data access.
  • B. A stored procedure is a precompiled set of SQL statements, often used for complex operations or business logic, but not primarily for simplifying data access as a virtual table.
  • D. A materialized view stores the result-set of a query physically, improving performance for frequently accessed complex queries, but the primary goal here is simplification and consistent access, not necessarily performance optimization first.

Database View

A virtual table based on the result-set of a SQL query. It does not store data itself but rather displays data stored in other tables.

  • Simplifies complex queries by abstracting underlying table structures.
  • Can be used for security, restricting user access to specific rows/columns.
  • Data is dynamic, always reflecting the current state of the base tables.

Memory trick: Views are windows, procedures are scripts.

More Database Fundamentals questions