176k views
2 votes
Rows cannot be deleted from a table through a complex view that is based on a group function.

a. true
b. false

User Pierre F
by
8.1k points

1 Answer

4 votes

Final answer:

The statement that rows cannot be deleted from a table through a complex view based on a group function is true, due to SQL standards that ensure data integrity by preventing ambiguous deletions. The statement is 'true'.

Step-by-step explanation:

The statement 'Rows cannot be deleted from a table through a complex view that is based on a group function' is true. In SQL, a view is essentially a virtual table that is based on the result-set of a SQL statement. You can think of a view as a lens through which you can look at your data in different ways without affecting the actual underlying tables. When you create a view that involves a group function, such as SUM(), AVG(), MAX(), MIN(), or COUNT(), you are creating what is known as an aggregate view.

SQL standards generally prohibit the modification of data through a view that contains the following:

  • Group by or aggregate functions
  • JOINs that are not key-preserving
  • Distinct keyword
  • Subqueries
  • Certain other set operations

One primary reason for this limitation is that once a row is aggregated, the individual row that contributed to the aggregate is no longer distinct - it's been transformed into a summary or aggregate value. Since the view does not have a one-to-one correspondence with the table rows anymore, it becomes ambiguous which underlying table row should be affected by a DELETE operation. This ensures the integrity of the data by not allowing ambiguous deletions that could potentially corrupt the dataset.

Therefore, attempting to delete a row from such a complex view will usually result in an error indicating that the view is not updatable because it contains features such as group functions that violate the rules for updatable views.

User Jwh
by
7.0k points