-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 11, 2017 at 11:21 AM
-- Server version: 10.1.10-MariaDB
-- PHP Version: 7.0.4

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


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

--
-- Database: `ap_tool`
--

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

--
-- Table structure for table `action_point`
--

CREATE TABLE `action_point` (
  `ap_id` int(11) UNSIGNED NOT NULL,
  `ap_project_id` int(10) UNSIGNED NOT NULL,
  `action_point` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `date_done` timestamp NULL DEFAULT NULL,
  `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `assigned_to` int(11) UNSIGNED DEFAULT NULL,
  `status` enum('OPEN','ONGOING','DONE','CANCELLED') COLLATE utf8_unicode_ci NOT NULL,
  `project_id` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `ap_item`
--

CREATE TABLE `ap_item` (
  `item_id` int(10) UNSIGNED NOT NULL,
  `ap_project_id` int(10) UNSIGNED NOT NULL,
  `ap_id` int(11) UNSIGNED NOT NULL,
  `item` text COLLATE utf8_unicode_ci NOT NULL,
  `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `ap_item_decision`
--

CREATE TABLE `ap_item_decision` (
  `decision_id` int(10) UNSIGNED NOT NULL,
  `item_id` int(10) UNSIGNED NOT NULL,
  `decision` text COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `ap_project`
--

CREATE TABLE `ap_project` (
  `ap_project_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `ap_project_user`
--

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

--
-- Indexes for dumped tables
--

--
-- Indexes for table `action_point`
--
ALTER TABLE `action_point`
  ADD UNIQUE KEY `ap_id` (`ap_id`,`ap_project_id`),
  ADD KEY `ap_project_id` (`ap_project_id`),
  ADD KEY `ap_id_2` (`ap_id`);

--
-- Indexes for table `ap_item`
--
ALTER TABLE `ap_item`
  ADD PRIMARY KEY (`item_id`),
  ADD KEY `ap_project_id` (`ap_project_id`),
  ADD KEY `ap_id` (`ap_id`);

--
-- Indexes for table `ap_item_decision`
--
ALTER TABLE `ap_item_decision`
  ADD PRIMARY KEY (`decision_id`);

--
-- Indexes for table `ap_project`
--
ALTER TABLE `ap_project`
  ADD PRIMARY KEY (`ap_project_id`);

--
-- Indexes for table `ap_project_user`
--
ALTER TABLE `ap_project_user`
  ADD UNIQUE KEY `project_id` (`project_id`,`user_id`),
  ADD KEY `fk_common_userid` (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `ap_item`
--
ALTER TABLE `ap_item`
  MODIFY `item_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=221;
--
-- AUTO_INCREMENT for table `ap_item_decision`
--
ALTER TABLE `ap_item_decision`
  MODIFY `decision_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
--
-- AUTO_INCREMENT for table `ap_project`
--
ALTER TABLE `ap_project`
  MODIFY `ap_project_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `action_point`
--
ALTER TABLE `action_point`
  ADD CONSTRAINT `action_point_ibfk_1` FOREIGN KEY (`ap_project_id`) REFERENCES `ap_project` (`ap_project_id`);

--
-- Constraints for table `ap_item`
--
ALTER TABLE `ap_item`
  ADD CONSTRAINT `ap_item_ibfk_1` FOREIGN KEY (`ap_project_id`) REFERENCES `ap_project` (`ap_project_id`);

--
-- Constraints for table `ap_project_user`
--
ALTER TABLE `ap_project_user`
  ADD CONSTRAINT `fk_ap_project_id` FOREIGN KEY (`project_id`) REFERENCES `ap_project` (`ap_project_id`);

/*!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 */;
