Results 1 to 2 of 2

Thread: Structure of MySQL Database

  1. #1
    Join Date
    Sep 2008

    Structure of MySQL Database

    I'm trying to create a community to learn more about coding php, ajax and sql. One thing I'm wondering about is how you usually structure databases for communities/forums.

    I want to have user information and pm's on the site. Do I create a database each? One for users and one for pm? Is it enough with just a table for all the users?

    I was thinking that the information I need when sending pm's is mainly a user id, sender id and some content. Is every user then supposed to have their own table for pm's or should I have one big where I search the table for a matching user id and then display the result for the user?

    Is there something I missed? Please comment about things you think are good to keep in mind when working with databases I would very much appreciate getting some answers to all my questions.

  2. #2
    Join Date
    Aug 2004
    A single database is all you should need. Separate tables would be used to model separate things, with additional tables as needed to model relationships between those things. So as far as the PM stuff goes, at a minimum you would have two tables: users and pms. The pms table might be something like:
    • id (int, primary key, auto-increment)
    • sender_user_id (an id from the users table)
    • receiver_user_id (*ditto*)
    • pm_subject
    • pm_text
    • timestamp

    You might want to do some reading at:
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center