Cách tiếp cận bên dưới có thể giúp bạn sắp xếp. Đây là cơ sở tốt cho cả trò chuyện và nhắn tin, ở đó với trò chuyện, bạn có thể thăm dò ý kiến các tin nhắn gần đây từ phía khách hàng và tát vào giao diện người dùng trực quan.
Message {
MessageId,
SenderId, -- Foreign key User.UserId
DateSent,
Subject,
Content,
Attachment, -- can be null or default to a 0
...
}
UserMessage {
Id,
MessageId, -- Foreign key Message.MessagId
RecepientId, -- Foreign key User.UserId
DateRead -- can default to year 1900 if you do not want to deal with nulls
}
User {
UserId
UserName
...
}
Queries
Read = UserMessage where DateRead > year 1900 (or not equal to null)
Inbox = UserMessage where RecepientId = Me.UserId
Sent = Message where SenderId = Me.UserId
Conversation = Group by Subject
Attachment = (Simple = Path to attachment file. || Better = DocumentId ... see below)
Attachment
Document {
int DocumentId,
int DocTypeId,
virtual DocumentType DocumentType,
string FileName,
int UserId,
string mimeType,
float fileSize,
string storagePath,
int OrganizationId,
string fileHash,
string ipAddress,
DateTime DateCreated = DateTime.Now;
}
cách chúng tôi có thể triển khai điều này trong MySQL? –