Bird
0
0

You want to create an audit logging system that records who made changes and when. Which combination of PostgreSQL features should you use?

hard📝 Workflow Q8 of 15
PostgreSQL - Triggers in PostgreSQL
You want to create an audit logging system that records who made changes and when. Which combination of PostgreSQL features should you use?
AForeign keys to link audit table to users
BViews with SELECT permissions for audit
CTrigger functions with session_user and current_timestamp inserted into audit table
DIndexes on audit table for faster logging
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to capture user and time in audit logs

    Using trigger functions, you can insert session_user and current_timestamp into audit tables on data changes.
  2. Step 2: Exclude unrelated features

    Views and indexes do not capture user or time; foreign keys link data but don't log changes.
  3. Final Answer:

    Trigger functions with session_user and current_timestamp inserted into audit table -> Option C
  4. Quick Check:

    Audit logs need triggers capturing user and time [OK]
Quick Trick: Use triggers with session_user and timestamp for audit [OK]
Common Mistakes:
  • Using views which don't log changes
  • Relying on indexes for audit data
  • Confusing foreign keys with audit logging

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes