-- phpMyAdmin SQL Dump
-- version 4.2.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 18, 2016 at 12:00 PM
-- Server version: 5.5.44-0+deb8u1-log
-- PHP Version: 5.6.13-0+deb8u1

SET FOREIGN_KEY_CHECKS=0;
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 utf8 */;

--
-- Database: `dip_bdg`
--

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

--
-- Table structure for table `article`
--

CREATE TABLE IF NOT EXISTS `article` (
`article_id` int(10) unsigned NOT NULL,
  `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `fs` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Fleet Service',
  `sp` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Service Pack',
  `dr` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Damage Repair',
  `is` tinyint(1) NOT NULL DEFAULT '-1' COMMENT 'InSurance',
  `pc` tinyint(1) NOT NULL DEFAULT '-1' COMMENT 'Power Care'
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `company`
--

CREATE TABLE IF NOT EXISTS `company` (
`company_id` int(10) unsigned NOT NULL,
  `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `country_code` varchar(2) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `company_article`
--

CREATE TABLE IF NOT EXISTS `company_article` (
  `company_id` int(10) unsigned NOT NULL,
  `article_id` int(10) unsigned NOT NULL,
  `year` smallint(6) NOT NULL DEFAULT '2016',
  `total` smallint(6) NOT NULL DEFAULT '0',
  `fs` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Fleet Service',
  `sp` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Service Pack',
  `dr` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Damage Repair',
  `is` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Insured',
  `pc` mediumint(9) NOT NULL DEFAULT '0' COMMENT 'Power care'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `sale_budget`
--

CREATE TABLE IF NOT EXISTS `sale_budget` (
  `year` int(11) NOT NULL,
  `country_code` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
  `article_id` int(10) unsigned NOT NULL,
  `company_id` int(10) unsigned NOT NULL,
  `fs` tinyint(1) NOT NULL,
  `sp` tinyint(1) NOT NULL,
  `january` int(11) NOT NULL DEFAULT '0',
  `february` int(11) NOT NULL DEFAULT '0',
  `march` int(11) NOT NULL DEFAULT '0',
  `april` int(11) NOT NULL DEFAULT '0',
  `may` int(11) NOT NULL DEFAULT '0',
  `june` int(11) NOT NULL DEFAULT '0',
  `july` int(11) NOT NULL DEFAULT '0',
  `august` int(11) NOT NULL DEFAULT '0',
  `september` int(11) NOT NULL DEFAULT '0',
  `october` int(11) NOT NULL DEFAULT '0',
  `november` int(11) NOT NULL DEFAULT '0',
  `december` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `user_country`
--

CREATE TABLE IF NOT EXISTS `user_country` (
  `user_id` int(10) unsigned NOT NULL,
  `country_code` varchar(2) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `article`
--
ALTER TABLE `article`
 ADD PRIMARY KEY (`article_id`);

--
-- Indexes for table `company`
--
ALTER TABLE `company`
 ADD PRIMARY KEY (`company_id`), ADD UNIQUE KEY `name` (`name`);

--
-- Indexes for table `company_article`
--
ALTER TABLE `company_article`
 ADD UNIQUE KEY `company_article` (`company_id`,`article_id`), ADD KEY `article_id` (`article_id`);

--
-- Indexes for table `sale_budget`
--
ALTER TABLE `sale_budget`
 ADD UNIQUE KEY `unique_budget` (`year`,`country_code`,`article_id`,`company_id`), ADD KEY `country` (`country_code`), ADD KEY `article_code` (`article_id`), ADD KEY `company_id` (`company_id`);

--
-- Indexes for table `user_country`
--
ALTER TABLE `user_country`
 ADD UNIQUE KEY `user_country` (`user_id`,`country_code`), ADD KEY `user_id` (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `article`
--
ALTER TABLE `article`
MODIFY `article_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `company`
--
ALTER TABLE `company`
MODIFY `company_id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=33;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `company_article`
--
ALTER TABLE `company_article`
ADD CONSTRAINT `company_article_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `company` (`company_id`) ON UPDATE CASCADE,
ADD CONSTRAINT `company_article_ibfk_2` FOREIGN KEY (`article_id`) REFERENCES `article` (`article_id`) ON UPDATE CASCADE;

--
-- Constraints for table `sale_budget`
--
ALTER TABLE `sale_budget`
ADD CONSTRAINT `sale_budget_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `company` (`company_id`) ON UPDATE CASCADE;

--
-- Constraints for table `user_country`
--
ALTER TABLE `user_country`
ADD CONSTRAINT `user_country_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `dip`.`user` (`user_id`);
SET FOREIGN_KEY_CHECKS=1;

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