Chat Server - Chapter 20 / Page 686, Structure of mysql table behind the Chat server example |
![]() ![]() |
Chat Server - Chapter 20 / Page 686, Structure of mysql table behind the Chat server example |
Feb 7 2009, 08:44 AM
Post
#1
|
|
|
|
Fellows,
I would apprecite if someone could provide the script that is used to create teh tables behind the Chat Server example. Thanks, |
|
|
|
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! |
|
|
|
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.
|
|
|
|
Aug 21 2009, 07:07 AM
Post
#4
|
|
|
|
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.
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 21st November 2009 - 04:33 AM |