--
-- Database: `dip_scrumtool`
--

-- --------------------------------------------------------

--
-- Table structure for table `criteria`
--

CREATE TABLE `criteria` (
  `criteria_id` int(10) NOT NULL,
  `story_id` int(10) NOT NULL,
  `criteria` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `decisions`
--

CREATE TABLE `decisions` (
  `decisions_id` int(11) NOT NULL,
  `project_id` int(11) NOT NULL,
  `submitted_by` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `date_submitted` int(11) NOT NULL,
  `item` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `decisions` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `approved` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `definitions_of_done`
--

CREATE TABLE `definitions_of_done` (
  `dod_id` int(11) NOT NULL,
  `project_id` int(11) NOT NULL,
  `text` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `definitions_of_ready`
--

CREATE TABLE `definitions_of_ready` (
  `dor_id` int(11) NOT NULL,
  `project_id` int(11) NOT NULL,
  `text` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_backlog`
--

CREATE TABLE `product_backlog` (
  `story_id` int(11) NOT NULL,
  `project_id` int(11) NOT NULL,
  `tag_id` int(10) UNSIGNED DEFAULT NULL,
  `date_created` varchar(11) CHARACTER SET utf8 NOT NULL,
  `story` text COLLATE utf8_unicode_ci,
  `as_a` varchar(255) CHARACTER SET utf8 NOT NULL,
  `i_want_to` varchar(255) CHARACTER SET utf8 NOT NULL,
  `so_that` varchar(255) CHARACTER SET utf8 NOT NULL,
  `days` int(11) NOT NULL,
  `status` enum('CONCEPT','DEFINED','SPRINT','DONE','REJECTED') CHARACTER SET utf8 NOT NULL,
  `sort_order` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `projects`
--

CREATE TABLE `projects` (
  `project_id` int(5) NOT NULL,
  `project_title` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `product_owner` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `scrum_master` int(10) UNSIGNED NOT NULL,
  `sprint_length` tinyint(3) UNSIGNED NOT NULL,
  `start_date` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `projects_developers`
--

CREATE TABLE `projects_developers` (
  `project_id` int(11) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `sprints`
--

CREATE TABLE `sprints` (
  `sprint_id` int(10) NOT NULL,
  `project_id` int(10) NOT NULL,
  `sprint_nr` smallint(6) NOT NULL,
  `start_date` varchar(11) CHARACTER SET utf8 NOT NULL,
  `end_date` varchar(11) CHARACTER SET utf8 NOT NULL,
  `active` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `sprint_goals`
--

CREATE TABLE `sprint_goals` (
  `goal_id` int(10) UNSIGNED NOT NULL,
  `sprint_id` int(10) NOT NULL,
  `goal` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `sprint_stories`
--

CREATE TABLE `sprint_stories` (
  `sprint_id` int(11) NOT NULL,
  `story_id` int(11) NOT NULL,
  `story_status` enum('START','ONGOING','VERIFY','DONE') DEFAULT NULL,
  `done_date` int(11) DEFAULT NULL,
  `verified_by` int(11) DEFAULT NULL,
  `assigned_to` int(11) DEFAULT NULL,
  `progress` decimal(3,2) DEFAULT NULL,
  `days` decimal(4,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `sprint_tasks`
--

CREATE TABLE `sprint_tasks` (
  `task_id` int(11) NOT NULL,
  `story_id` int(11) NOT NULL,
  `sprint_id` int(11) NOT NULL,
  `task` varchar(255) NOT NULL,
  `comment` varchar(255) DEFAULT NULL,
  `task_status` enum('OPEN','ONGOING','DONE') NOT NULL,
  `done_date` int(11) DEFAULT NULL,
  `assigned_to` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `tags`
--

CREATE TABLE `tags` (
  `tag_id` int(10) UNSIGNED NOT NULL,
  `project_id` int(5) NOT NULL,
  `text` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `criteria`
--
ALTER TABLE `criteria`
  ADD PRIMARY KEY (`criteria_id`),
  ADD KEY `criteria_ibfk_1` (`story_id`);

--
-- Indexes for table `decisions`
--
ALTER TABLE `decisions`
  ADD PRIMARY KEY (`decisions_id`),
  ADD KEY `fk_Project_Id` (`project_id`),
  ADD KEY `project_id` (`project_id`);

--
-- Indexes for table `definitions_of_done`
--
ALTER TABLE `definitions_of_done`
  ADD PRIMARY KEY (`dod_id`),
  ADD KEY `project_id` (`project_id`);

--
-- Indexes for table `definitions_of_ready`
--
ALTER TABLE `definitions_of_ready`
  ADD PRIMARY KEY (`dor_id`),
  ADD KEY `project_id` (`project_id`);

--
-- Indexes for table `product_backlog`
--
ALTER TABLE `product_backlog`
  ADD PRIMARY KEY (`story_id`),
  ADD UNIQUE KEY `pb_id` (`story_id`,`project_id`),
  ADD KEY `fk_project` (`project_id`),
  ADD KEY `fk_backlog_tags` (`tag_id`);

--
-- Indexes for table `projects`
--
ALTER TABLE `projects`
  ADD PRIMARY KEY (`project_id`),
  ADD UNIQUE KEY `project_title` (`project_title`),
  ADD KEY `product_owner` (`product_owner`),
  ADD KEY `scrum_master` (`scrum_master`);

--
-- Indexes for table `projects_developers`
--
ALTER TABLE `projects_developers`
  ADD PRIMARY KEY (`project_id`,`user_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `sprints`
--
ALTER TABLE `sprints`
  ADD PRIMARY KEY (`sprint_id`),
  ADD KEY `project_id` (`project_id`);

--
-- Indexes for table `sprint_goals`
--
ALTER TABLE `sprint_goals`
  ADD PRIMARY KEY (`goal_id`),
  ADD KEY `fk_goals_sprints` (`sprint_id`);

--
-- Indexes for table `sprint_stories`
--
ALTER TABLE `sprint_stories`
  ADD PRIMARY KEY (`sprint_id`,`story_id`),
  ADD KEY `ss_fk_storyid` (`story_id`),
  ADD KEY `sprints_fk_sprintid` (`sprint_id`);

--
-- Indexes for table `sprint_tasks`
--
ALTER TABLE `sprint_tasks`
  ADD PRIMARY KEY (`task_id`),
  ADD KEY `tasks_fk_StoryId` (`story_id`),
  ADD KEY `tasks_fk_SprintId` (`sprint_id`);

--
-- Indexes for table `tags`
--
ALTER TABLE `tags`
  ADD PRIMARY KEY (`tag_id`),
  ADD KEY `fk_tags_projects` (`project_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `criteria`
--
ALTER TABLE `criteria`
  MODIFY `criteria_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `decisions`
--
ALTER TABLE `decisions`
  MODIFY `decisions_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `definitions_of_done`
--
ALTER TABLE `definitions_of_done`
  MODIFY `dod_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `definitions_of_ready`
--
ALTER TABLE `definitions_of_ready`
  MODIFY `dor_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `product_backlog`
--
ALTER TABLE `product_backlog`
  MODIFY `story_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `sprints`
--
ALTER TABLE `sprints`
  MODIFY `sprint_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `sprint_goals`
--
ALTER TABLE `sprint_goals`
  MODIFY `goal_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `sprint_tasks`
--
ALTER TABLE `sprint_tasks`
  MODIFY `task_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `tags`
--
ALTER TABLE `tags`
  MODIFY `tag_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `criteria`
--
ALTER TABLE `criteria`
  ADD CONSTRAINT `criteria_ibfk_1` FOREIGN KEY (`story_id`) REFERENCES `product_backlog` (`story_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `decisions`
--
ALTER TABLE `decisions`
  ADD CONSTRAINT `decisions_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`),
  ADD CONSTRAINT `fk_Project_Id` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `definitions_of_done`
--
ALTER TABLE `definitions_of_done`
  ADD CONSTRAINT `definitions_of_done_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `definitions_of_ready`
--
ALTER TABLE `definitions_of_ready`
  ADD CONSTRAINT `definitions_of_ready_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_backlog`
--
ALTER TABLE `product_backlog`
  ADD CONSTRAINT `product_backlog_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `projects`
--

--
-- Constraints for table `projects_developers`
--
ALTER TABLE `projects_developers`
  ADD CONSTRAINT `projects_developers_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `sprints`
--
ALTER TABLE `sprints`
  ADD CONSTRAINT `sprints_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `sprint_stories`
--
ALTER TABLE `sprint_stories`
  ADD CONSTRAINT `sprint_stories_ibfk_1` FOREIGN KEY (`story_id`) REFERENCES `product_backlog` (`story_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `sprints_fk_sprintid` FOREIGN KEY (`sprint_id`) REFERENCES `sprints` (`sprint_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `sprint_tasks`
--
ALTER TABLE `sprint_tasks`
  ADD CONSTRAINT `tasks_fk_SprintId` FOREIGN KEY (`sprint_id`) REFERENCES `sprints` (`sprint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `tasks_fk_StoryId` FOREIGN KEY (`story_id`) REFERENCES `product_backlog` (`story_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `tags`
--
ALTER TABLE `tags`
  ADD CONSTRAINT `fk_tags_projects` FOREIGN KEY (`project_id`) REFERENCES `projects` (`project_id`) ON UPDATE CASCADE;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
