CREATE TABLE `form` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `nazov` varchar(100) DEFAULT NULL,
  `code` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

CREATE TABLE `form_element_type` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

CREATE TABLE `form_group` (
  `id` int(11) unsigned NOT NULL,
  `form_id` int(11) unsigned NOT NULL,
  `nazov` varchar(100) DEFAULT NULL,
  `code` varchar(50) DEFAULT NULL,
  `position` int(11) DEFAULT NULL,
  `poznamka` text,
  PRIMARY KEY (`id`),
  KEY `form_group_FKIndex1` (`form_id`),
  CONSTRAINT `fk_form_group_form` FOREIGN KEY (`form_id`) REFERENCES `form` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `form_element` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `form_group_id` int(11) unsigned NOT NULL,
  `form_element_type_id` int(11) unsigned NOT NULL,
  `db_table` varchar(255) DEFAULT NULL,
  `db_column` varchar(50) DEFAULT NULL,
  `db_multi_table` varchar(100) DEFAULT NULL,
  `db_multivalue_table` varchar(100) DEFAULT NULL,
  `column_title` varchar(255) DEFAULT NULL,
  `position` int(11) DEFAULT NULL,
  `width` int(11) DEFAULT NULL,
  `height` int(11) DEFAULT NULL,
  `help` varchar(255) DEFAULT NULL,
  `example` varchar(255) DEFAULT NULL,
  `direct_to_db` tinyint(1) unsigned DEFAULT NULL,
  `required` tinyint(1) unsigned DEFAULT NULL,
  `number` tinyint(1) unsigned DEFAULT NULL,
  `float_number` tinyint(1) unsigned DEFAULT NULL,
  `email` tinyint(1) unsigned DEFAULT NULL,
  `css_style` varchar(200) DEFAULT NULL,
  `css_class` varchar(50) DEFAULT NULL,
  `javascript` text,
  `direct_multi_label` tinyint(1) unsigned DEFAULT NULL,
  `direct_multi_data` tinyint(1) unsigned DEFAULT NULL,
  `default_val` varchar(100) DEFAULT NULL,
  `vdaemon` text,
  `add_empty_option` tinyint(1) unsigned DEFAULT NULL,
  `html` text,
  `lang_code` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `form_element_FKIndex1` (`form_element_type_id`),
  KEY `form_element_FKIndex2` (`form_group_id`),
  CONSTRAINT `fk_form_element_form_group` FOREIGN KEY (`form_group_id`) REFERENCES `form_group` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_form_element_form_element_type` FOREIGN KEY (`form_element_type_id`) REFERENCES `form_element_type` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

INSERT INTO `form_element_type` (`id`,`code`) VALUES (1,'text');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (2,'textarea');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (3,'checkbox');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (4,'date');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (5,'select');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (6,'multicheckbox');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (7,'fckeditor');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (8,'password');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (9,'multilistbox');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (10,'ckeditor');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (11,'datetime');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (12,'fcbkcomplete');
INSERT INTO `form_element_type` (`id`,`code`) VALUES (13,'hidden');