Posted 18 September 2006 - 09:15 AM
Posted 18 September 2006 - 09:52 AM
So have a user table that only stores user info, make sure it has and auto-incrementing ID field, you can use this as your primary key and use it to relate to other tables.
Then have a messages_in table that contains only received messages, a message_out table that contains only sent messages, these tables can be linked via a column so that replies can be tied up with their original message. etc. etc.
Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools
Posted 18 September 2006 - 09:56 AM
Posted 18 September 2006 - 11:31 AM
Database tables should be split where functionality differs. User tables contain user info only. Message tables, only messages info. Where you have information that applies to two (or more) tables, use a foreign key to the table that is relevant for that information.
Such as the messages will need to know who sent/received it. So use the user id of the user as a foreign key, then you can select the message from the messages table, then the user info from the users table where the id's match.. (in a JOIN statement.)
This is the process of Database normalisation.
Also, don't create a new table for every user. That would be like creating a whole new database for every user.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users