## This is a schema for MySQL for 
## the concept of Users/Roles/Permissions
##
## Please see the Html documentation for more information 
## on this SQL. Equivalent contributions of this for other 
## databases are welcome.

## The default database should be named "Turbine"
## This is created with the command "mysqladmin create Turbine"
#drop database if exists Turbine;
#create database Turbine;

## This schema is imported into MySQL with the command:
## mysql Turbine < MySQL_users_roles_permissions.sql



create table Permission  (
    PERMISSIONID        integer AUTO_INCREMENT PRIMARY KEY,
    PERMISSION          varchar (99) NOT NULL,
    UNIQUE (PERMISSION)
);




create table UserRole  (
    ROLEID      integer AUTO_INCREMENT PRIMARY KEY,
    ROLENAME    varchar (99) NOT NULL,
    UNIQUE (ROLENAME)
);




create table RolePermission  (
    ROLEID              integer NOT NULL,
    PERMISSIONID        integer NOT NULL,
    PRIMARY KEY (ROLEID, PERMISSIONID),
    INDEX roleID_permissionID_index ( ROLEID, PERMISSIONID )
);


create table VisitorRole  (
    VISITORID   integer NOT NULL,
    ROLEID      integer NOT NULL,
    PRIMARY KEY (VISITORID, ROLEID),
    INDEX visitorID_roleID_index ( VISITORID, ROLEID )
);


create table Jobentry  (
    OID	          int(11) NOT NULL PRIMARY KEY,
    MINUTE        integer default -1 NOT NULL,
    HOUR          integer default -1 NOT NULL,
    WEEKDAY       integer default -1 NOT NULL,
    DAY_OF_MONTH  integer default -1 NOT NULL,
    TASK          varchar(99) NOT NULL,
    EMAIL         varchar(99)
);







