www.webdeveloper.com
Results 1 to 2 of 2

Thread: Structure of MySQL Database

  1. #1
    Join Date
    Sep 2008
    Posts
    52

    Structure of MySQL Database

    Hi!
    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
    Location
    Ankh-Morpork
    Posts
    18,926
    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:
    http://dev.mysql.com/tech-resources/...alization.html
    http://www.geekgirls.com/menu_databases.htm
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles