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.
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*)
You might want to do some reading at:
"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
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)