Hello,
I’m thinking of building a chat system for a website I’m working on but I need some advice on the database structure and queries.
I’m thinking of having something like this:
users table - id, username, hash
messages table - id, message
users_messages table - sender_id, message_id, recipient_id
query - SELECT messages.message FROM users_messages WHERE recipient_id = $id LEFT OUTER JOIN messages ON users_messages.message_id = messages.id
Does the above code look alright? I haven’t tested it I was just thinking it through first. Also, would a query like that make the database run slow if there was thousands of messages to search through? Hope this makes sense
Thanks,
Adam