I am trying to make a small messaging system. It should have these properties:
- One user can send a message to one or many users
- Messages can be sent only to registered users (i.e. to an existing 'idUser' record)
- There should be tracking of sent messages (who sent the message and to whom)
Here is how the current database design looks like:
Table Private Message stores only the content of the message.
Table User Private Message is used to keep track of sent messages. It has columns "idUser from" and "idUser to" which indicate the user that sent the message and the user (can be more than one) that received the message.
I am having difficulties with choosing the right type of relationship (if the whole concept is correct in the first place) for the tables "User" and "User Private Message". I assume that there should be two separate relationships for the tables 'User' and 'User Private Message', like this:
- One-to-one relationship, that connects
User
.idUser
andUser Private Message
.idUser from
- One-to-many relationship, that connects
User
.idUser
andUser Private Message
.idUser to
Could you please advise me on what relationship to use here. If you have any suggestions on how to approach this type of problem easier, I would appreciate that even more.
Thank you all for your time.