CREATE DATABASE booking;

USE booking;

CREATE TABLE roombooking
(bid INTEGER NOT NULL AUTO_INCREMENT,
sdate TIMESTAMP NOT NULL,
edate TIMESTAMP NOT NULL,
room INTEGER NOT NULL,
comment VARCHAR(20) NOT NULL DEFAULT '',
uid INTEGER NOT NULL,
PRIMARY KEY(bid),
FOREIGN KEY(uid) REFERENCES user(uid) ON UPDATE CASCADE ON DELETE CASCADE)TYPE = InnoDB;

drop table roombooking;


SELECT * FROM roombooking ORDER BY sdate, room;


CREATE TABLE message 
(id INTEGER NOT NULL AUTO_INCREMENT,
datim TIMESTAMP NOT NULL, 
name VARCHAR(30) NOT NULL DEFAULT '', 
email VARCHAR(30) NOT NULL DEFAULT '',
homepage VARCHAR(30) NOT NULL DEFAULT '',
comment VARCHAR(40) NOT NULL DEFAULT '', 
PRIMARY KEY(id))TYPE = InnoDB;

CREATE TABLE Image
(id INTEGER NOT NULL,
pic MEDIUMBLOB NOT NULL,
mime VARCHAR(15) NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY(id) 
REFERENCES message(id)
ON UPDATE CASCADE ON DELETE CASCADE)TYPE = InnoDB;

