create database Zope;
use Zope;

#
# Table structure for table 'MiscData'
#
CREATE TABLE MiscData (
  OId int(11) DEFAULT '0' NOT NULL,
  OClass char(15) DEFAULT '' NOT NULL,
  MId char(30) DEFAULT '' NOT NULL,
  Value_int int(11),
  Value_string char(100),
  PRIMARY KEY (OId,OClass,MId)
);

#
# Table structure for table 'Roles'
#
CREATE TABLE Roles (
  Id int(11) DEFAULT '0' NOT NULL auto_increment,
  Rolename char(20) DEFAULT '' NOT NULL,
  Realm char(10) DEFAULT '' NOT NULL,
  PRIMARY KEY (Id),
  UNIQUE Realm (Realm,Rolename)
);

#
# Table structure for table 'Sessions'
#
CREATE TABLE Sessions (
  Id int(11) DEFAULT '0' NOT NULL auto_increment,
  Id_User int(11) DEFAULT '0' NOT NULL,
  PRIMARY KEY (Id)
);

#
# Table structure for table 'Tokens'
#
CREATE TABLE Tokens (
  Id int(11) DEFAULT '0' NOT NULL,
  Class char(15) DEFAULT '' NOT NULL,
  Value char(50),
  Created double(16,4) DEFAULT '0.0000' NOT NULL,
  Accessed double(16,4) DEFAULT '0.0000' NOT NULL,
  Timeout int(11) DEFAULT '0' NOT NULL,
  Life int(11) DEFAULT '0' NOT NULL,
  Realm char(10) DEFAULT '' NOT NULL,
  PRIMARY KEY (Id,Class)
);

#
# Table structure for table 'UserRoles'
#
CREATE TABLE UserRoles (
  Id_User int(11) DEFAULT '0' NOT NULL,
  Id_Role int(11) DEFAULT '0' NOT NULL,
  PRIMARY KEY (Id_User,Id_Role),
  KEY Id_User (Id_User),
  KEY Id_Role (Id_Role)
);

#
# Table structure for table 'Users'
#
CREATE TABLE Users (
  Id int(11) DEFAULT '0' NOT NULL auto_increment,
  Username char(60) DEFAULT '' NOT NULL,
  Realname char(50),
  Password char(32),
  PasswordType int(11) DEFAULT '0' NOT NULL,
  Domains char (160) DEFAULT '' NOT NULL,
  Realm char(10) DEFAULT '' NOT NULL,
  EMail char(60),
  PRIMARY KEY (Id),
  UNIQUE Realm (Realm,Username)
);

#
# Table structure for table 'Log'
#

CREATE TABLE Log (
  Id int(11) NOT NULL auto_increment,
  Realm char(10) DEFAULT '' NOT NULL,
  Id_Session int(11),
  Event char(10) DEFAULT '' NOT NULL,
  EValue char(200),
  EValue2 char(200),
  OType char(30),
  OSize int(11),
  RAddr char (15),
  Time timestamp(14),
  PRIMARY KEY (Id)
);

