Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Chat Server - Chapter 20 / Page 686, Structure of mysql table behind the Chat server example
Etanefo
post Feb 7 2009, 08:44 AM
Post #1


New Member
*

Group: Members
Posts: 1
Joined: 7-February 09
Member No.: 2,236



Fellows,

I would apprecite if someone could provide the script that is used to create teh tables behind the Chat Server example.

Thanks,
Go to the top of the page
 
+Quote Post
anthony3
post Feb 9 2009, 07:16 AM
Post #2


Active Member
**

Group: O'Reilly Author
Posts: 14
Joined: 17-September 08
From: Shiloh, IL
Member No.: 911



There are two tables needed for this (very very) basic chat system, users and messages. Obviously for a real system, you would want to add user creation, passwords, etc. to make it more reasonably professional. That being said, here is the answer to your question:

CODE
/* this table holds the basic user information (and can/should be expanded) */
CREATE TABLE users (
user_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(20) NOT NULL UNIQUE KEY,
passwd VARCHAR(255) NOT NULL, /* not used in book example */
logged_in BIT NOT NULL DEFAULT 0,
last_log DATETIME NULL
);

/* this table holds the messages for cthe chatting queue */
CREATE TABLE messages (
message_id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id INTEGER NOT NULL REFERENCES users(user_id),
message VARCHAR(255) NOT NULL,
msg_dte DATETIME NOT NULL
);


Let me know if you have any more questions, and good luck!
Go to the top of the page
 
+Quote Post
anthony3
post Aug 6 2009, 07:12 AM
Post #3


Active Member
**

Group: O'Reilly Author
Posts: 14
Joined: 17-September 08
From: Shiloh, IL
Member No.: 911



No problem. Glad I could help.
Go to the top of the page
 
+Quote Post
Seemi
post Aug 21 2009, 07:07 AM
Post #4


Active Member
**

Group: Members
Posts: 20
Joined: 21-August 09
Member No.: 19,829



QUOTE (anthony3 @ Feb 9 2009, 07:16 AM) *
There are two tables needed for this (very very) basic chat system, users and messages. Obviously for a real system, you would want to add user creation, passwords, etc. to make it more reasonably professional. That being said, here is the answer to your question:

CODE
/* this table holds the basic user information (and can/should be expanded) */
CREATE TABLE users (
user_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(20) NOT NULL UNIQUE KEY,
passwd VARCHAR(255) NOT NULL, /* not used in book example */
logged_in BIT NOT NULL DEFAULT 0,
last_log DATETIME NULL
);

/* this table holds the messages for cthe chatting queue */
CREATE TABLE messages (
message_id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id INTEGER NOT NULL REFERENCES users(user_id),
message VARCHAR(255) NOT NULL,
msg_dte DATETIME NOT NULL
);


Let me know if you have any more questions, and good luck!


That really solved the problem..
Thanks Anthony!


--------------------
Does Someone Do Medical Assistant Jobs like me? then please guide me to start a Medical Assistant Career.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 21st November 2009 - 04:33 AM