I am using a SQL table to store all my users along with their relevant information. Each user can sometimes have messages sent to them by another user, and I'm having trouble figuring out how to store these messages, and connecting them with the correct receiving user.
I've thought of making a new table called messages that contains all the messages of all the users, and each time a user logs in it will query and display all the messages pertaining to that user. However, I'm not sure if this is the best approach to this problem or whether it will get quite slow after thousands or hundreds of thousands of messages.
Is this method viable, or is there a better way to accomplish this?