Databases · Middle · Question 56 of 75
How would you store a user's changing subscription plans so you can see the history?
- 1Create a new user row for every plan change
- ✓Correct answer: A separate table of plan periods (
user_id,plan,valid_from,valid_to) instead of one overwritten column - 3Overwrite
users.planand log changes in a text file
Explanation
History tables make questions like 'what plan did they have on March 1?' easy. PostgreSQL range types and exclusion constraints can prevent overlapping periods.