Bird
0
0

You need an updatable view that displays employee names along with their department names. Since joining tables prevents updates, which design is best?

hard📝 Application Q8 of 15
SQL - Views
You need an updatable view that displays employee names along with their department names. Since joining tables prevents updates, which design is best?
ACreate a view joining employees and departments with GROUP BY on department
BCreate a view on employees only and use a function or application logic to fetch department names
CCreate a view with aggregate functions to combine employee and department data
DCreate a view selecting all columns from both tables without any WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: Understand the limitation

    Views with joins are not updatable because the DBMS cannot determine which table to update.
  2. Step 2: Find a workaround

    Creating a view on employees only keeps it updatable; department names can be retrieved separately via functions or application logic.
  3. Final Answer:

    Create a view on employees only and use a function or application logic to fetch department names -> Option B
  4. Quick Check:

    Separate department info outside view to keep it updatable [OK]
Quick Trick: Avoid joins in updatable views; use functions or app logic instead [OK]
Common Mistakes:
MISTAKES
  • Trying to join tables in the view for display
  • Using GROUP BY or aggregates to combine data
  • Selecting all columns from multiple tables expecting updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes