Jump to content

Recommended Posts

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

 

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

 

 

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.

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.

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.

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.

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.

 

 

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,
)";

 

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!";

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.