I have 3 tables for a messaging system
Conversations
| id |
Participants
| id | conversation | user |
Messages
| id | conversation | user | text |
I want to restrict messages being inserted into a conversation if the user is not part of through the participants table
I think I could structure it in a better way by having participant in the messages table. But then id have to do an extra query by seeing what a users participant id is before inserting a message.
Id rather do it with a constraint or foreign key. What would the best way to do this be?