CREATE TABLE IF NOT EXISTS `mailing_data_pattern` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `mailing_data_pattern_field` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mailing_data_pattern_id` int(11) NOT NULL,
  `code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `default_value` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `description` text COLLATE utf8_unicode_ci,
  `use_default_if_empty` int(11) DEFAULT '0',
  `mandatory` int(11) DEFAULT '0',
  `max_length` int(11) DEFAULT NULL,
  `filler` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mailing_data_pattern_id` (`mailing_data_pattern_id`,`code`),
  KEY `mailing_data_pattern_field_FI_1` (`mailing_data_pattern_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;