I have been thinking of implementing a PHP messaging system on my site. Would like to know pros and cons of my following suggestion.
Many sites I noticed like spareroom.co.uk, easyroommate.com, oasis.com, facebook etc you can login and message users/profiles. So for user to send messages they have to login to my site then enter msg into textarea which I store it in a MYSQL db table. The recipient user then receives a real email to hotmail/gmail notifying him to go to my site & login and check their messages and they can then reply/send on my site only.
My messaging table will be like:
sender email address (varchar)(50)
sender advert id (varchar)(7)
sender message (text)
recipient email address (varchar)(50)
recipient advert id (varchar)(7)
So each message sent from sender/recipient would be a new record
I already have 3 other tables in my db (this being 4th). I will automatically delete messages after say 7 days. Hopefully this will get users coming back to my site and using it. I know it will use bandwidth but it will ensure my site is being used and users are receiving email messages as my email server seems to go their real email providers spam/junk mail box.
Questions:
1)Is it good idea to have a db with loads of records but few fields?
2)Is there any pros/cons to this suggestion?
3)Do sites using PHP implement their message systems in a similar sort of way?
Cheers,
daza166
When I set up a database I never care about the number of fields of a particular table. Somethimes it is necessary to only store an information that something is locked, so I use a table with only one field. Sometimes I need to know if an item with a particular property already has been created, so I store only the property in a separate table an perform a lookup over all entries to find whether this property is already in use or not.
From the point of performance or best practice: You approach is in any way the right one.