I have the following tables in my database:
Above these tables (not pictured) is a Users table where the SendingUserId and ReceivingUserId are keyed onto (they are foreign keys).
Are these tables in a normalized form? I feel as if I'm missing something.. maybe the SendingUserId and ReceivingUserId should be a composite key in the UsersWithMessages table?
As long as one message can have no more than one sender and no more than one receiver, you do not have a many-to-many
relationship.
Since your Message
table already contains SendingUserId
and ReceivingUserId
, just make them Foreign Keys (FK) and you would not need UsersWithMessages
table at all.
You will have a simple two-table schema: User
and Message
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.