redarrow Posted March 14, 2009 Share Posted March 14, 2009 I am currently going to create a message system. Can you kindly tell me, if there any think wrong with the database structure before i design it. sent messages table. id // id of the row. users_id // id of the user sent_id // id of the sent message. subject // message subject of user message //message of the user. date // timestamps of the message block // yes or no of block default no. spam // 0 or 1 of spam 0 default alart // 0 or 1 of alert 0 default. received messages table. id // id of the row. users_id // users id received_id // id of the received message. subject // message subject of user message // message of the user date // time stamp off the messages. block // yes or no of block default no. spam // 0 or 1 of spam 0 default alart // 0 or 1 of alert 0 default Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 can you think off anything else please. maybe protect the number off time a user sends a message? don't no sent message. id // id of the row. users_id // id of the user sent_id // id of the sent message. subject // message subject of user message //message of the user. add a url // let user add a url of a web site. add a file // let the user add a file. users email // users email from database if they want a copy sent to them send a copy // 0 or 1 default 0 read_message // 0 or 1 default 0 date // timestamps of the message block // yes or no of block default no. spam // 0 or 1 of spam 0 default alert // 0 or 1 of alert 0 default. received message id // id of the row. users_id // users id received_id // id of the received message. subject // message subject of user message // message of the user add a url // let user add a url of a web site. add a file // let the user add a file. users email // users email from database if they want a copy sent to them send a copy // 0 or 1 default 0 read_message // 0 or 1 default 0 date // time stamp off the messages. block // yes or no of block default no. spam // 0 or 1 of spam 0 default alert // 0 or 1 of alert 0 default Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 can i use 1 table with sent_id and received_id instead off two tables. example. id // id of the row. sent_id // id of the sent message. received_id // id of received id. subject // message subject of user message //message of the user. add a url // let user add a url of a web site. add a file // let the user add a file. users email // users email from database if they want a copy sent to them send a copy // 0 or 1 default 0 read_message // 0 or 1 default 0 date // timestamps of the message block // yes or no of block default no. spam // 0 or 1 of spam 0 default alert // 0 or 1 of alert 0 default. Quote Link to comment Share on other sites More sharing options...
Ayon Posted March 14, 2009 Share Posted March 14, 2009 i would do "sender_id" // id of the sender "revicer_id" // id of the reciver you don't need to do a id of the sent message... because that would only return the same as "id" Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 are you saying this looks fine as one table then for messages. id // id of the row. sent_id // id of the sent message. received_id // id of received id. subject // message subject of user message //message of the user. add a url // let user add a url of a web site. add a file // let the user add a file. users email // users email from database if they want a copy sent to them send a copy // 0 or 1 default 0 read_message // 0 or 1 default 0 date // timestamps of the message block // yes or no of block default no. spam // 0 or 1 of spam 0 default alert // 0 or 1 of alert 0 default. Quote Link to comment Share on other sites More sharing options...
Ayon Posted March 14, 2009 Share Posted March 14, 2009 i would do something like this msg_id // message ID sender_id // userID of the sender reciver_id // userID of the reciver subject // message subject of user message //message of the user. add_url // let user add a url of a web site. add_file // let the user add a file. user_email // users email from database if they want a copy sent to them send_copy // 0 or 1 default 0 read_message // 0 or 1 default 0 date // timestamps of the message block // yes or no of block default no. spam // 0 or 1 of spam 0 default alert // 0 or 1 of alert 0 default. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 you done nothing different means the same as mine except i understand your a bit better. lol That means when you press a link to send the message, you update the sent_id first before the message get sent , if using 1 table. Quote Link to comment Share on other sites More sharing options...
Ayon Posted March 14, 2009 Share Posted March 14, 2009 oh haha xD well then i must have misunderstood your comments... thought your "sent_id" & "recived_id" was going to be unique message id's xD my bad then hehe Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 your funny still like yours better. is it true that the sent_id get first updated, before the user even sends the message, or update all info via session's at once. Quote Link to comment Share on other sites More sharing options...
Ayon Posted March 14, 2009 Share Posted March 14, 2009 msg_id should be the main ID column that just keep on counting and counting ... make it auto_increment and PRIMARY key the rest should be inserted by your addmessage script Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 well users will have the chance to mail other user's, so the id off the current user sending the message will have there id in a session. the receiver's id will be in a link as the user press to send the message get me. $_SESSION['sender_id'] // current user sending a message. $_GET['reciver_id']; // the user that receiving the message id from link am i correct sorry brain dead today. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 my default gives error, what have i done wrong please. $sql3="CREATE TABLE users_messages( msg_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, sender_id INT NOT NULL, reciver_id INT NOT NULL, subject VARCHAR(250) NOT NULL, message TEXT NOT NULL, add_url VARCHAR(250) NOT NULL, add_file VARCHAR(250) NOT NULL, user_email VARCHAR(250) NOT NULL, send_copy ENUM ('0','1') DEFUALT(0) NOT NULL, read_message ENUM ('0','1') DEFUALT(0) NOT NULL, date INT(70) NOT NULL, block ENUM ('yes','no') DEFUALT(no) NOT NULL, spam ENUM ('0','1') DEFUALT(0) NOT NULL, alert ENUM ('0','1') DEFUALT(0) NOT NULL, )"; Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 14, 2009 Author Share Posted March 14, 2009 the winning code yee haaaaaaaaa my spelling so bad unreal. <?php $connect_database=mysql_connect("localhost","root","password") or die("Databse connection problam".mysql_error()); $sql="CREATE DATABASE messages"; $sql_res1=mysql_query($sql)or die(mysql_error()); $sql2="USE messages"; $sql_res2=mysql_query($sql2)or die(mysql_error()); $sql3="CREATE TABLE users_messages(msg_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, sender_id INT NOT NULL, reciver_id INT NOT NULL, subject VARCHAR(250) NOT NULL, message TEXT NOT NULL, add_url VARCHAR(250) NOT NULL, add_file VARCHAR(250) NOT NULL, user_email VARCHAR(250) NOT NULL, send_copy ENUM ('0','1') DEFAULT '0' NOT NULL, read_message ENUM ('0','1') DEFAULT '0' NOT NULL, date INT(70) NOT NULL, block ENUM ('yes','no') DEFAULT 'no' NOT NULL, spam ENUM ('0','1') DEFAULT '0' NOT NULL, alert ENUM ('0','1') DEFAULT '0' NOT NULL )"; $sql_res3=mysql_query($sql3)or die(mysql_error()); if($sql_res3){ echo"database created!!!!!!!!!!!!!!!!"; }else{ echo"Sorry no database created!"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.