?
Solved

Database question

Posted on 2011-03-07
3
Medium Priority
?
330 Views
Last Modified: 2012-12-13
Hi all,

We have been asked to extend a database we wrote t handle a 'email' style message service (similar to facebook and google). So each user would have their own inbox and sent items listing.

for the message structure I am not so sure how to structure it because one thing they want (similar to facebook or gmail) is that the linked messages look like a conversation? so how will I related these? Also how would I handle sending o multiple recipients?

message
messageID
userID
subject - string
message - text
date - timestamp

messageSentUser
messageID
userID

this is where i'm unsure?

messageLink
messageID
messageID
order - int

any ideas??
thanks in advance.
0
Comment
Question by:flynny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
raulggonzalez earned 2000 total points
ID: 35055304
HI,

I'd go for a similar but slightly different solution.

Create a table MessagesThreads
ID,

And other messagesInThreads
ID,
ThreadID,
MessageID

for a new message you create a new threadID and for any reply/forward  you use the same threadID like the parent object.

If you use messageId, messageId, whay will happen when you have a really long thread?

In my case, you just need to check the threadId or to group by it to have all the messages which belong to the same conversation...

 Good luck
0
 

Author Comment

by:flynny
ID: 35056458
Great solution.

Just to check I've got the jist of everything we'd have something like the following;

Thread,
ID

MessageThread
ID
ThreadID (referring to thread table Id)
MessageID (referring to table below )

Message
ID
UserID (link to user sending email)
Subject
Message
Date

MessageUser
MessageID
UserID (to allow for multiple sent)

Then when a user goes to their inbox we would simply have to search the thread table intersected with the message and user table (to get the relevant threads started by the user)

Is the id field in he messagethread table needed can we simply have a joint key on the thread and messageid? Or am I missing something?
0
 
LVL 8

Expert Comment

by:raulggonzalez
ID: 35056984
Well, actually you can 'get rid of' the ID in the table MessageThread and just have a compound PK ThreadID MessageID, but I always like having a unique PK instead of compound one.

You can create UNIQUE constraint over those two columns to guarantee the uniqueness of both values...

There are many ways to go the same place, look for the one you think fits better to your environment, needs ...


Good luck!  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question