L'approccio seguente dovrebbe essere in grado di risolvere l'utente. Questa è una buona base sia per la chat che per i messaggi, dove con la chat è possibile eseguire il polling dei messaggi recenti dal lato client e eseguire uno slap su un'interfaccia utente intuitiva.
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;
}
come possiamo implementarlo in MySQL? –