scenario:
users leave comments on certain works, etc. A single table in the database stores these messages, which contains information such as the user"s profile picture and nickname.
Scheme:
- user id, is used in the comment table to associate with the user table
- each comment record directly stores the user"s id, profile picture and nickname together for easy reading.
question?
solution 1 was originally planned, but if there are more comments, you need to traverse each comment, take out the user id, query the information in the user table, and return the information to the front end. Won"t this be very slow? such an interface will query the database many times.
Plan 2: it is unreliable when you think about it, and there will be a lot of problems, (1) waste of space, (2) it will be troublesome for users to update information
< hr >how do you deal with it? even if you tell me that Plan 1 is not slow, it is OK to dispel this doubt in my mind.
Please thank you