-- ---
-- Globals
-- ---

-- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- SET FOREIGN_KEY_CHECKS=0;

-- ---
-- Table 'data_capture_forms'
-- Data Capture Form Management
-- ---

DROP TABLE IF EXISTS `data_capture_forms`;
         
CREATE TABLE `data_capture_forms` (
  `id` INTEGER NOT NULL AUTO_INCREMENT,
  `brand` VARCHAR(255) NULL DEFAULT NULL,
  `button_label` VARCHAR(40) NULL DEFAULT NULL,
  `feedback_title` VARCHAR(255) NULL DEFAULT NULL,
  `form_subtitle` VARCHAR(255) NULL DEFAULT NULL,
  `submit_button` VARCHAR(40) NULL DEFAULT NULL,
  `close_button` VARCHAR(40) NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) COMMENT='Data Capture Form Management';

-- ---
-- Table 'data_capture_questions'
--
-- ---

DROP TABLE IF EXISTS `data_capture_questions`;
         
CREATE TABLE `data_capture_questions` (
  `id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
  `form_id` INTEGER NULL DEFAULT NULL,
  `question_text` VARCHAR(255) NULL DEFAULT NULL,
  `answers` VARCHAR(255) NULL DEFAULT NULL,
  `form_type` VARCHAR(10) NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
);

-- ---
-- Table 'data_capture_reporting'
-- Tracking data for data capture reports
-- ---

DROP TABLE IF EXISTS `data_capture_reporting`;
         
CREATE TABLE `data_capture_reporting` (
  `id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
  `form_id` INTEGER NULL DEFAULT NULL,
  `answer` INTEGER NULL DEFAULT NULL,
  `date` TIMESTAMP NULL DEFAULT NULL,
  `referrer` VARCHAR(255) NULL DEFAULT NULL,
  `email` VARCHAR(50) NULL DEFAULT NULL,
  `details` VARCHAR(255) NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) COMMENT='Tracking data for data capture reports';

-- ---
-- Foreign Keys
-- ---

ALTER TABLE `data_capture_questions` ADD FOREIGN KEY (form_id) REFERENCES `data_capture_forms` (`id`);
ALTER TABLE `data_capture_reporting` ADD FOREIGN KEY (form_id) REFERENCES `data_capture_forms` (`id`);

-- ---
-- Table Properties
-- ---

-- ALTER TABLE `data_capture_forms` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ALTER TABLE `data_capture_questions` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ALTER TABLE `data_capture_reporting` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ---
-- Test Data
-- ---

-- INSERT INTO `data_capture_forms` (`id`,`brand`,`button_label`,`feedback_title`,`form_subtitle`,`submit_button`,`close_button`) VALUES
-- ('','','','','','','');
-- INSERT INTO `data_capture_questions` (`id`,`form_id`,`question_text`,`answers`,`form_type`) VALUES
-- ('','','','','');
-- INSERT INTO `data_capture_reporting` (`id`,`form_id`,`answer`,`date`,`referrer`,`email`,`details`) VALUES
-- ('','','','','','','');




<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://127.0.0.1/sqldesigner/ -->
<sql>
<datatypes db="mysql">
     <group label="Numeric" color="rgb(238,238,170)">
          <type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
          <type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
          <type label="Single precision" length="0" sql="FLOAT" quote=""/>
          <type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/>
     </group>

     <group label="Character" color="rgb(255,200,200)">
          <type label="Char" length="1" sql="CHAR" quote="'"/>
          <type label="Varchar" length="1" sql="VARCHAR" quote="'"/>
          <type label="Text" length="0" sql="MEDIUMTEXT" re="TEXT" quote="'"/>
          <type label="Binary" length="1" sql="BINARY" quote="'"/>
          <type label="Varbinary" length="1" sql="VARBINARY" quote="'"/>
          <type label="BLOB" length="0" sql="BLOB" re="BLOB" quote="'"/>
     </group>

     <group label="Date &amp; Time" color="rgb(200,255,200)">
          <type label="Date" length="0" sql="DATE" quote="'"/>
          <type label="Time" length="0" sql="TIME" quote="'"/>
          <type label="Datetime" length="0" sql="DATETIME" quote="'"/>
          <type label="Year" length="0" sql="YEAR" quote=""/>
          <type label="Timestamp" length="0" sql="TIMESTAMP" quote="'"/>
     </group>
    
     <group label="Miscellaneous" color="rgb(200,200,255)">
          <type label="ENUM" length="1" sql="ENUM" quote=""/>
          <type label="SET" length="1" sql="SET" quote=""/>
          <type label="Bit" length="0" sql="bit" quote=""/>
     </group>
</datatypes><table x="658" y="132" name="data_capture_forms">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default></row>
<row name="brand" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default></row>
<row name="button_label" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default></row>
<row name="feedback_title" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Ad Feedback: The title of the form</comment>
</row>
<row name="form_subtitle" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Ad Feedback: the subtitle of the form (optional)</comment>
</row>
<row name="submit_button" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Text for the submit button</comment>
</row>
<row name="close_button" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Ad Feedback: Text for the close button.</comment>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
<comment>Data Capture Form Management</comment>
</table>
<table x="766" y="445" name="data_capture_questions">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default></row>
<row name="form_id" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default><relation table="data_capture_forms" row="id" />
</row>
<row name="question_text" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default></row>
<row name="answers" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Stored as an array of questions, separated by ampersand.</comment>
</row>
<row name="form_type" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Possible values are: radio or dropdown</comment>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="1118" y="364" name="data_capture_reporting">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default></row>
<row name="form_id" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default><relation table="data_capture_forms" row="id" />
<comment>The ID of the data capture form</comment>
</row>
<row name="answer" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default><comment>The # of the answer the user selected. </comment>
</row>
<row name="date" null="1" autoincrement="0">
<datatype>TIMESTAMP</datatype>
<default>NULL</default><comment>Timestamp of when the question was answered.</comment>
</row>
<row name="referrer" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>The URL of the referring site.</comment>
</row>
<row name="email" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Ad Feedback: The email of the user who submitted feedback.</comment>
</row>
<row name="details" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default><comment>Ad Feedback: the text from the description text area.</comment>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
<comment>Tracking data for data capture reports</comment>
</table>
</sql>




               "aoColumns": [
                              /* Type */   { "bVisible":    false },
                              /* ID */  null,
                              /* Brand */  null,
                              /* Button label */  null,
                              /* Title */    null
                              /* Subtitle */  null,
                              /* Submit Button */  null,
                              /* Cancel button */  null
                         ]