Re: PhP database design question



chris.withers@xxxxxxxxx wrote:
I have built a web portal and was considering adding a 'user mail'
feature for users to message each other. I'm a bit uncertain on how to
design the DB, so was wondering if there is a standard to do this. I
was figuring perhaps a table storing all user messages (but this might
become very large very fast?) or would a seperate db storing
sent/saved/recieved etc messages be better?

Any advice would be appreciated,


Chris


Ps I'm unsure if this is the right group, but couldn;t find anything
concerning php and Dbs which seemed more appropriate.


Hi, Chris,

First of all, no, this isn't the "wrong group" for the question. I don't know what a "right group" would be :-).

There's no real standard for designing the DB for something like this. It's up to you how to do it.

If I were doing it, I would keep the body of the message in a separate table, something like:

First table:
msgid
from
to
date
subject
status (sent/received/saved)

Second table:
msgid
msgtext

The reason for keeping the message itself separate is speed. As you note, the file could become very big. You don't want the messages every time you scan - for instance, when you display the list of messages available to the user. Keeping the text in a separate table will speed up these requests, at least with MySQL. Of course, displaying the actual message will be slightly slower, but you won't be doing that as much as just displaying to/from/subject.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: non-standard functions in libc -- bad design?
    ... the C standard, what happens when "foo" is added to the next C ... it's an awful design to start with. ... why not put B in a separate library from A and C ... define and maintain a consistent API between the two libraries such ...
    (comp.unix.programmer)
  • Re: Target market for Intellasys.
    ... I would like to see a full speed general purpose embedded serial interconnect IO bus standard. ... Looking through serial memory I found something like a maximum of 70mhz speed which is pretty useless if it was the only bus in a cutting edge design. ... All other control mode levels also have this ability, to allow developer to instigate their own versions of the features not defined in that level, as they wish, if they wish. ...
    (comp.lang.forth)
  • Re: gets(); was: Re: Why does rewind() ignore errors?
    ... useful as any other input function standard C delivers. ... Ever programmed a big system havin about 300 little applications as ... There can be a simple stream whoes source is somewhere on the world ... Programming starts with design. ...
    (comp.std.c)
  • Re: Interface standards (was Re: Dual Port RAM)
    ... I find there lack of a standard on the 'internal' side to be ... principle of abstraction; instead of hiding complex functions behind ... simple interfaces, ... write the code for because it is just a sub-function of the overall design. ...
    (comp.arch.fpga)
  • Re: Design for historical data
    ... > types of visits are really that, 3 separate types of visits, which store ... billion rows of page delivery history in a system I helped build (I know ... Good design is important, decent, well balanced hardware (disk, ... Pro SQL Server 2000 Database Design - ...
    (microsoft.public.sqlserver.programming)