Solved

Database question

Posted on 2011-03-07
3
322 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
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
raulggonzalez earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now