CREATE DATABASE guestbookimage;

USE guestBookImage;

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;

