-- phpMyAdmin SQL Dump
-- version 4.6.6deb5
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Mar 05, 2019 at 03:46 PM
-- Server version: 10.3.13-MariaDB-1:10.3.13+maria~cosmic-log
-- PHP Version: 7.2.15-0ubuntu0.18.10.1

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: `NestedQueries`
--

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

--
-- Table structure for table `NIC4`
--

CREATE TABLE `NIC4` (
  `NICId` int(11) NOT NULL COMMENT 'Primary Key',
  `PeriodId` int(11) NOT NULL COMMENT 'Tax Period Id',
  `LowBand` decimal(13,4) NOT NULL COMMENT 'Start P&L for low band',
  `HighBand` decimal(13,4) NOT NULL COMMENT 'Start P&L for high band',
  `Rate` decimal(10,4) NOT NULL COMMENT 'Rate for NI',
  `HighRate` decimal(10,4) NOT NULL COMMENT 'Rate for NI in high band'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='NIC4 Rate';

--
-- Dumping data for table `NIC4`
--

INSERT INTO `NIC4` (`NICId`, `PeriodId`, `LowBand`, `HighBand`, `Rate`, `HighRate`) VALUES
(1, 2, '4535.0000', '29900.0000', '0.0700', '0.0000'),
(2, 7, '4615.0000', '30420.0000', '0.0700', '0.0000'),
(3, 13, '4615.0000', '30940.0000', '0.0800', '0.0100'),
(4, 16, '4745.0000', '31720.0000', '0.0800', '0.0100'),
(5, 37, '4895.0000', '32760.0000', '0.0800', '0.0100'),
(6, 46, '5035.0000', '33540.0000', '0.0800', '0.0100'),
(7, 52, '5225.0000', '34840.0000', '0.0800', '0.0100'),
(8, 58, '5435.0000', '40040.0000', '0.0800', '0.0100'),
(9, 68, '5715.0000', '43875.0000', '0.0800', '0.0100');

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

--
-- Table structure for table `ReportingPeriod`
--

CREATE TABLE `ReportingPeriod` (
  `PeriodId` int(11) NOT NULL COMMENT 'Primary Key',
  `From` int(11) NOT NULL COMMENT 'Start Date yyymmdd',
  `To` int(11) NOT NULL COMMENT 'End date yyymmdd',
  `IncomeTax` tinyint(1) NOT NULL COMMENT 'True if Income Tax period'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reporting Period';

--
-- Dumping data for table `ReportingPeriod`
--

INSERT INTO `ReportingPeriod` (`PeriodId`, `From`, `To`, `IncomeTax`) VALUES
(2, 20010406, 20020405, 1),
(7, 20020406, 20030405, 1),
(13, 20030406, 20040405, 1),
(16, 20040406, 20050405, 1),
(37, 20050406, 20060405, 1),
(46, 20060406, 20070405, 1),
(52, 20070406, 20080405, 1),
(58, 20080406, 20090405, 1),
(68, 20090406, 20100405, 1),
(69, 20100406, 20110405, 1),
(72, 20110406, 20120405, 1),
(73, 20120406, 20130405, 1),
(76, 20130406, 20140405, 1),
(79, 20140406, 20150405, 1),
(105, 20150406, 20160405, 1),
(106, 20160406, 20170405, 1),
(107, 20170406, 20180405, 1),
(108, 20180406, 20190405, 1),
(109, 20190406, 20200405, 1),
(110, 20200405, 20210405, 1);

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

--
-- Table structure for table `TaxSelection`
--

CREATE TABLE `TaxSelection` (
  `RowId` smallint(6) NOT NULL COMMENT 'One row only',
  `TaxPeriodId` int(11) NOT NULL COMMENT 'Tax Year'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `TaxSelection`
--

INSERT INTO `TaxSelection` (`RowId`, `TaxPeriodId`) VALUES
(0, 37);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `NIC4`
--
ALTER TABLE `NIC4`
  ADD PRIMARY KEY (`NICId`),
  ADD KEY `PeriodId` (`PeriodId`);

--
-- Indexes for table `ReportingPeriod`
--
ALTER TABLE `ReportingPeriod`
  ADD PRIMARY KEY (`PeriodId`),
  ADD UNIQUE KEY `FromTo` (`From`,`To`);

--
-- Indexes for table `TaxSelection`
--
ALTER TABLE `TaxSelection`
  ADD PRIMARY KEY (`RowId`),
  ADD UNIQUE KEY `TaxPeriodId` (`TaxPeriodId`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `NIC4`
--
ALTER TABLE `NIC4`
  MODIFY `NICId` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key', AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `ReportingPeriod`
--
ALTER TABLE `ReportingPeriod`
  MODIFY `PeriodId` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key', AUTO_INCREMENT=111;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `NIC4`
--
ALTER TABLE `NIC4`
  ADD CONSTRAINT `NIC4_ibfk_1` FOREIGN KEY (`PeriodId`) REFERENCES `ReportingPeriod` (`PeriodId`) ON UPDATE CASCADE;

--
-- Constraints for table `TaxSelection`
--
ALTER TABLE `TaxSelection`
  ADD CONSTRAINT `TaxSelection_ibfk_2` FOREIGN KEY (`TaxPeriodId`) REFERENCES `ReportingPeriod` (`PeriodId`) ON DELETE NO ACTION ON UPDATE NO ACTION;

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