Dragen Posted April 26, 2008 Share Posted April 26, 2008 Hi, I'm writing a messaging system for an online shop where users can contact merchants and vice-versa. Now I'm fine with writing the form, databases etc I've just got a question on how best to do something. In the code I need to check whether the sender/recipient is a normal user or a merchant, so it can get the user information from the correct table (one for merchants, another for users). This is mainly for display replies, so it can show who it was from. At the moment I'm getting the sender's account type when they send a message and storing it along with the message as it's the only way I can think of doing it. Does anyone else have any ideas? I mean on websites when you send a support ticket, how do they keep track of whether replies are from the user or the support personnel (I'm assuming they won't be stored in the same table)? Thanks Link to comment https://forums.phpfreaks.com/topic/103054-solved-keep-track-of-message-sender/ Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 they are stored in the same table. there is one table with a flag to indicate whether the record is a user or support personnel. thus, a single identifier points to a single person, instead of having to also use a second variable (table identifier). you should try to avoid duplicating data as much as possible (i.e., normalize your database.) Link to comment https://forums.phpfreaks.com/topic/103054-solved-keep-track-of-message-sender/#findComment-527858 Share on other sites More sharing options...
Dragen Posted April 26, 2008 Author Share Posted April 26, 2008 yeah, fair enough. The reason I'm using separate tables though is because the accounts work completely differently with lots of variations in the tables themselves, so having them as one table wouldn't make it easier. I may look into merging the two tables an decide on which method to use. Link to comment https://forums.phpfreaks.com/topic/103054-solved-keep-track-of-message-sender/#findComment-527869 Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 there are probably similar fields between the 2 types of people (first name, last name, phone number, email address). so you could create one table for 'people', then link them via record id to different tables depending on what type of people they are, like 'user_information' and 'support_information' Link to comment https://forums.phpfreaks.com/topic/103054-solved-keep-track-of-message-sender/#findComment-527874 Share on other sites More sharing options...
Dragen Posted April 26, 2008 Author Share Posted April 26, 2008 yeah, that's an idea! Thanks. I'm marking this solved. Link to comment https://forums.phpfreaks.com/topic/103054-solved-keep-track-of-message-sender/#findComment-527921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.