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
|
CREATE TABLE `user` (
`id` INT NOT NULL AUTO_INCREMENT ,
`lastname` VARCHAR(255) NOT NULL ,
`firstname` VARCHAR( 255 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `reservationuser` (
`id_user` INT NOT NULL ,
`id_reservation` INT NOT NULL ,
PRIMARY KEY ( `id_user` ),
CONSTRAINT `user_fk_constraint` FOREIGN KEY (`id_user`)
REFERENCES `user` (`id`),
CONSTRAINT `user_reserv_fk_constraint` FOREIGN KEY (`id_reservation`)
REFERENCES `reservation` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `reservation` (
`id` INT NOT NULL AUTO_INCREMENT ,
`id_room` INT NOT NULL ,
`date_begin` DATE NOT NULL ,
`date_end` DATE NOT NULL ,
`usage` VARCHAR( 255 ) NOT NULL ,
`creator` INT NOT NULL ,
CONSTRAINT `creator_fk_constraint` FOREIGN KEY (`creator`)
REFERENCES `user` (`id`),
CONSTRAINT `room_fk_constraint` FOREIGN KEY (`id_room`)
REFERENCES `room` (`id`),
PRIMARY KEY ( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `room` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 255 ) NOT NULL ,
`capacity` INT NOT NULL ,
PRIMARY KEY ( `Id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
insert into `user` VALUES(1,'aa','bb','cc@xx.fr','xxx');
insert into `user` VALUES(2,'dd','ee','dd@xx.fr','xxx');
insert into `room` VALUES(1,'zend',100);
insert into `reservation` VALUES(1,1,NOW(),NOW(),'azerty',1);
insert into `reservationuser` VALUES(1,1); |
Partager