Should a datbase reflect a user's actions or user's state?
1
vote
3
answers
53
views
We have a Postgres DB in which we store a "settings" JSON field on Users. This JSON field indicates (among other things) whether the user is subscribed to a digest we send out. There's some model validation that ensures that values in this key / value pair operate like an enum.
We're going to try an experiment in which we auto-subscribe users who visit the site (we know their email addresses because we're a small network).
We are debating how the user's subscription state should be modeled in the DB. One team member thinks the DB should reflect the user's *actions*, so the "subscribed" value in the JSON should remain NULL until the user explicitly changes it, and we should send emails to users who have "subscribed" == NULL and who have visited the site. Another team member thinks the DB should reflect the user's subscription *state*, so the "subscribed" value in the JSON should be set to true once the user visits the site for the first time.
Which philosophy do others in this forum think is more common and/or intuitive?
Asked by duhaime
(121 rep)
Dec 13, 2023, 06:52 PM
Last activity: Dec 14, 2023, 07:12 AM
Last activity: Dec 14, 2023, 07:12 AM