CREATE TABLE `diary_cat` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`desc` varchar(100) default NULL,
PRIMARY KEY(`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `diary` (
`id` int(11) NOT NULL auto_increment,
`id_cat` int(11) NOT NULL,
`name` varchar(64) NOT NULL,
`msg` varchar(10000) NOT NULL,
`id_user` int(11) NOT NULL,
`readers` set('0', '1', '2') NOT NULL default '0',
`viewings` int(11) NOT NULL default '0',
`rating` int(11) NOT NULL default '0',
`tags` varchar(128) default NULL,
`time` int(11) NOT NULL,
PRIMARY KEY(`id`, `name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `diary_rating` (
`id_diary` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`rating` int(11) NOT NULL default '0',
KEY `id_diary` (`id_diary`, `id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `diary_komm` (
`id` int(11) NOT NULL auto_increment,
`id_diary` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`time` int(11) NOT NULL,
`msg` varchar(1024) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `diary_images` (
`id` int(11) NOT NULL auto_increment,
`id_diary` int(11) NOT NULL,
`position` set('up', 'down') NOT NULL default 'up',
`ras` varchar(4) NOT NULL,
PRIMARY KEY(`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;