Answer the question
In order to leave comments, you need to log in
Is a 1:1 relationship needed here instead of expanding the table?
There is a user table with quite standard fields and an updated_at field (well, that's how it should be).
In addition, I keep statistics for users in such a way that they can simply be added to the user table in new fields or separated into a separate user_stats table with a 1:1 relationship with user.
In the second case, I select a separate entity and, for example, add the updated_at field to user_stats, explicitly indicating that this is the statistics update time. Otherwise (in the case of one user table), I would have to specify the name of this field as stats_updated_at, while it is not clear which fields this stats_updated_at and just updated_at are responsible for updating.
In general, allocating a separate user_stats table seems more kosher, but you will have to put up with the user + user_stats join when making queries.
How are you doing?
Update 1:
Is it possible to somehow get out with the help of views / inheritance / other features of postgres by explicitly selecting two entities, while avoiding 1:1 and therefore a join?
Answer the question
In order to leave comments, you need to log in
You should not avoid join, nothing bad will come of it, do it kosher.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question