1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| DROP DATABASE IF EXISTS `skyr2`;
CREATE DATABASE `skyr2`;
USE `skyr2`;
CREATE TABLE `user`
(
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`login` VARCHAR( 255 ) UNIQUE NOT NULL ,
`passwd` BLOB ,
`mail` VARCHAR( 255 ) NOT NULL ,
`firstname` VARCHAR( 255 ) NOT NULL ,
`lastname` VARCHAR( 255 ) NOT NULL ,
`lang` VARCHAR( 2 ) NOT NULL ,
`company` INT( 4 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `company` ) ,
FOREIGN KEY ( `company` )
REFERENCES `company` ( `id` )
ON DELETE SET NULL
ON UPDATE CASCADE
) TYPE = InnoDB ;
CREATE TABLE `company`
(
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 255 ) UNIQUE ,
`contract` VARCHAR( 2 ) NOT NULL ,
`contry` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = InnoDB ;
CREATE TABLE `right`
(
`user` INT( 4 ) NOT NULL ,
`action` INT( 4 ) NOT NULL ,
PRIMARY KEY (`user`,`action`) ,
INDEX ( `user` ) ,
FOREIGN KEY ( `user` )
REFERENCES `user`(`id`)
ON DELETE SET NULL
ON UPDATE CASCADE ,
INDEX ( `action` ) ,
FOREIGN KEY (`action`)
REFERENCES action(`id`)
ON DELETE SET NULL
ON UPDATE CASCADE
) TYPE = InnoDB ;
CREATE TABLE `action`
(
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 255 ) UNIQUE NOT NULL ,
`label` VARCHAR( 255 ) NOT NULL ,
`file` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = InnoDB ; |
Partager