Solved

Database question

Posted on 2011-03-07
3
327 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 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
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…
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…

728 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