有如下表
消息记录
msg_record
from_id:发送者id
to_id:接收方id
msg:消息内容
msg_type:消息类型[文本图片]
用户表
user_info
id 用户id
nick 用户昵称
header 头像
sex 性别
user_to_user
私聊对象
from_id发送者id
to_id 对方id【此处是1多关系】
每次查看私聊消息列表只要
select to_id from user_to_user where from_id = id
一个人可能和多个人聊天,但是同时多个人也可能和一个人聊天
那么假如存在一条记录 {from_id:1,to_id:2}
是否要同时在表中插入一条{from_id:2,to_id:1}
否则select to_id from user_to_user where from_id = 2将查不到数据,
请问这个设计问题该如何解决?
请教高手!
这只是“我发出的消息”,不是“私聊消息列表”。