Bird
0
0

You want to create an updatable view that joins employees and departments but still allows updates to employee names. Which approach is correct?

hard📝 Application Q8 of 15
PostgreSQL - Views and Materialized Views
You want to create an updatable view that joins employees and departments but still allows updates to employee names. Which approach is correct?
ACreate a materialized view instead of a regular view.
BCreate a simple view on employees only and ignore departments.
CUse GROUP BY in the view to aggregate department data.
DCreate the view with JOIN and add INSTEAD OF triggers to handle updates.
Step-by-Step Solution
Solution:
  1. Step 1: Understand join view limitations

    Views with JOINs are not updatable by default in PostgreSQL.
  2. Step 2: Use triggers to enable updates

    Adding INSTEAD OF triggers allows custom update logic on join views.
  3. Final Answer:

    Create the view with JOIN and add INSTEAD OF triggers to handle updates. -> Option D
  4. Quick Check:

    JOIN + triggers = updatable view [OK]
Quick Trick: Use INSTEAD OF triggers to update join views [OK]
Common Mistakes:
  • Ignoring triggers for join views
  • Using GROUP BY which blocks updates
  • Confusing materialized views with updatable views

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes