-- ----------------------------
-- Table structure for #__sr_feedbacks
-- ----------------------------
CREATE TABLE IF NOT EXISTS  `#__sr_feedbacks` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(225) NOT NULL,
  `reservation_id` int(10) unsigned NOT NULL DEFAULT '0',
  `positive` text,
  `negative` text,
  `like_count` int(11) unsigned DEFAULT '0',
  `dislike_count` int(11) unsigned DEFAULT '0',
  `state` tinyint(1) DEFAULT '0',
  `created_date` datetime DEFAULT '0000-00-00 00:00:00',
  `modified_date` datetime DEFAULT '0000-00-00 00:00:00',
  `feedback_cache` mediumtext NOT NULL,
  `scope` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `item_id` int(10) unsigned NOT NULL DEFAULT '0',
  `customer_name` varchar(255) NULL DEFAULT NULL,
  `customer_country_id` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci COMMENT='';

-- ----------------------------
-- Table structure for #__sr_feedback_attributes
-- ----------------------------

CREATE TABLE IF NOT EXISTS  `#__sr_feedback_attributes` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `scope` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Table structure for #__sr_feedback_conditions
-- ----------------------------

CREATE TABLE IF NOT EXISTS  `#__sr_feedback_conditions` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `field` varchar(64) DEFAULT NULL,
  `ordering` int(11) DEFAULT NULL,
  `scope` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Table structure for #__sr_feedback_scores
-- ----------------------------

CREATE TABLE IF NOT EXISTS  `#__sr_feedback_scores` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `feedback_id` int(11) unsigned DEFAULT NULL,
  `score` tinyint(3) unsigned DEFAULT NULL,
  `field_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_sr_feedback_scores_sr_feedbacks1_idx` (`feedback_id`),
  KEY `fk_sr_feedback_scores_sr_feedback_conditions1_idx` (`field_id`),
  CONSTRAINT `fk_sr_feedback_scores_sr_feedback_conditions1` FOREIGN KEY (`field_id`) REFERENCES `#__sr_feedback_conditions` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_sr_feedback_scores_sr_feedbacks1` FOREIGN KEY (`feedback_id`) REFERENCES `#__sr_feedbacks` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `#__sr_feedback_attribute_values` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `attribute_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_sr_feedback_attribute_values_sr_feedback_attribu_idx` (`attribute_id`),
  CONSTRAINT `fk_sr_feedback_attribute_values_sr_feedback_attributes1` FOREIGN KEY (`attribute_id`) REFERENCES `#__sr_feedback_attributes` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Table structure for #__sr_feedback_attribute_xref
-- ----------------------------

CREATE TABLE IF NOT EXISTS  `#__sr_feedback_attribute_xref` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `feedback_id` int(11) unsigned DEFAULT NULL,
  `feedback_attribute_value_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_sr_feedback_type_xref_sr_feedbacks1_idx` (`feedback_id`),
  KEY `fk_sr_feedback_attribute_xref_sr_feedback_attribute_idx` (`feedback_attribute_value_id`),
  CONSTRAINT `fk_jos_sr_feedback_attribute_xref_jos_sr_feedback_attribute_v1` FOREIGN KEY (`feedback_attribute_value_id`) REFERENCES `#__sr_feedback_attribute_values` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_sr_feedback_type_xref_sr_feedbacks1` FOREIGN KEY (`feedback_id`) REFERENCES `#__sr_feedbacks` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=131 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;