
drop table if exists UserInfo;

drop table if exists Room;

drop table if exists LoginHistory;

/*==============================================================*/
/* Table: LoginHistory                                          */
/*==============================================================*/
create table if not exists LoginHistory
(
   LoginID                        numeric(6,0)                   AUTO_INCREMENT,
   UserName                       varchar(20)                    not null,
   Alias                          varchar(20)                    not null,
   IP                             varchar(20)                    not null default 'a',
   LoginTime                      datetime                       not null,
   LogoutTime                     datetime                       not null,
   RoomID                         int                            not null
);

/*==============================================================*/
/* Table: Room                                                  */
/*==============================================================*/
create table if not exists Room
(
   RoomID                         int                            not null,
   RoomName                       varchar(20)                    not null,
   MaxUser                        int                            not null default 100,
   NearMaxUser                    int                            not null default 80,
   IniNo                          int                            not null default 1,
   TemplateNo                     int                            not null default 1,
   LogRoom                        int                            not null default 0,
   LogCommandInfo                 int                            not null default 1,
   LogUserLoginInfo               int                            not null default 1,
   LogSecret                      int                            not null default 1,
   LogIP                          int                            not null default 0,
   LastMessage                    int                            not null default 6,
   RoomType                       int                            not null default 0,
   AllowGuest                     int                            not null default 1,
   CompType                       int                            not null default 1,
   CryptType                      int                            not null default 1,
   AllowPublic                    int                            not null default 1,
   Background                     varchar(50)                    not null default '/images/bbb.jpg',
   LogoutUrl                      varchar(50)                    not null default '/',
   Administrators                 varchar(200)                   not null default 'admin',
   RoomTopic                      varchar(400)                   not null default '',
   RoomPassword                   varchar(20)                    not null default '',
   PrivateRoom                    int                            not null default 0,
   SupportAudio                   int                            not null default 1,
   SupportVideo                   int                            not null default 1,
   primary key (RoomID)
);


/*==============================================================*/
/* Table: UserInfo                                              */
/*==============================================================*/
create table if not exists UserInfo
(
   UserName                       varchar(20)                    not null,
   Alias                          varchar(20)                    not null,
   "Password"                     varchar(20)                    not null default 'a',
   Age                            int                            not null default 1,
   Sex                            int                            not null default 2,
   Grade                          int                            not null default 0,
   Credit                         int                            not null default 0,
   Email                          varchar(20)                    not null default 'a',
   Oicq                           varchar(20)                    not null default '',
   Icon                           varchar(20)                    not null default '',
   Photo                          varchar(20)                    not null default 'a',
   Resume                         varchar(200)                    not null default 'a',
   Guest                          int                            not null default 3,
   RegistTime                     datetime                       not null,
   LoginTime                      datetime                       not null,
   LogoutTime                     datetime                       not null,
   TotalTime                      int                            not null default 0,
   Question                       varchar(50)          not null default '',
   Answer                         varchar(50)          not null default '',
   "Status"                       int                            not null default 1,
   IP                             varchar(20)                    not null default 'a',
   RoomID                         int                            not null default 0,
   primary key (UserName)
);