I always wondered what is more efficient between two. There is one "main" table where I store all user related informations. Also, there are two more tables,
city table contains column country_id so I can relate to which country this city belongs.
Now, the main question : should I store only city_id in user table and query for country name using country_id from
city table or to store both, city_id and country_id ?
Other thing is related to counting. If have some fourth table, like
message, and I store ID of user who send message, ID of user who receive message, text, etc. Now, if I want to know how many messages some user sent, I can query for messages where sender=ID and count rows, but I used another approach. I created column count in user table and whenever user send message, I increase this number. Is this approach good and if no, is the first one efficient since that table can have billions of rows.