Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > Databases - MySQL, SQL, Oracle, Access and others
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-22-2006, 03:17 PM   #1 (permalink)
epochonaut
Junior Member
 
Join Date: Dec 2006
Posts: 7
Default database question

I'm just starting to teach myself how to do server-side stuff and I'm working on a website where members will be able to send private messages to each other. I've never considered how this works under the hood before. Are all PMs stored in a single table from which a query retrieves messages for a specific user? Does each new member get their own database table created to store their PMs? What is the best way to implement a private messaging feature?
epochonaut is offline   Reply With Quote
Sponsored Links
Old 01-02-2007, 12:31 AM   #2 (permalink)
alhefner
Junior Member
 
Join Date: Dec 2006
Posts: 21
Default Re: database question

The best way is with a single table. Try something like:

table name - pm

fields:
  • msg_id auto increment
  • sender_id (id of the user that sends the message)
  • to_id (id of the user message is for)
  • parent_msg (would be the id of an original msg if this is a reply)
  • msg_text (text of the msg)

oops! I forgot the date field! I would use an int type of field to store a unix timestamp for this.

Now, you have all the information for a user mailbox! inbox, sent, etc...

Queries will be very simple this way.

Al
__________________
My outdoor blog
alhefner is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 12:06 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums