Skip to content

Commit

Permalink
Added various database bits
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Aug 3, 2015
1 parent 48ffed1 commit dcce62d
Show file tree
Hide file tree
Showing 2 changed files with 239 additions and 0 deletions.
File renamed without changes
239 changes: 239 additions & 0 deletions db/magnum.sql
@@ -0,0 +1,239 @@
-- MySQL dump 10.15 Distrib 10.0.20-MariaDB, for Linux (x86_64)
--
-- Host: mag-sol.com Database: magnum
-- ------------------------------------------------------
-- Server version 5.5.41-MariaDB

/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `contract`
--

DROP TABLE IF EXISTS `contract`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contract` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer` int(11) NOT NULL DEFAULT '0',
`site` int(11) NOT NULL DEFAULT '0',
`start` date NOT NULL DEFAULT '0000-00-00',
`end` date DEFAULT NULL,
`rate` decimal(10,2) NOT NULL DEFAULT '0.00',
`rate_unit` char(10) NOT NULL DEFAULT '',
`hour_per_unit` decimal(10,2) NOT NULL DEFAULT '0.00',
`min_billed_units` decimal(10,2) NOT NULL DEFAULT '0.00',
`employee` int(11) NOT NULL DEFAULT '0',
`product` int(11) NOT NULL DEFAULT '0',
`cust_ref` varchar(200) DEFAULT NULL,
`cust_ref_desc` varchar(40) DEFAULT NULL,
`cust_contact` varchar(40) DEFAULT NULL,
`cust_contact_desc` varchar(40) DEFAULT NULL,
`disp_cust_contact` char(1) NOT NULL DEFAULT 'N',
PRIMARY KEY (`id`),
KEY `customer` (`customer`),
KEY `employee` (`employee`),
KEY `product` (`product`),
KEY `site` (`site`),
CONSTRAINT `contract_ibfk_1` FOREIGN KEY (`customer`) REFERENCES `customer` (`id`),
CONSTRAINT `contract_ibfk_2` FOREIGN KEY (`employee`) REFERENCES `employee` (`id`),
CONSTRAINT `contract_ibfk_3` FOREIGN KEY (`product`) REFERENCES `product` (`id`),
CONSTRAINT `contract_ibfk_4` FOREIGN KEY (`site`) REFERENCES `site` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `customer`
--

DROP TABLE IF EXISTS `customer`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `customer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
`address` varchar(255) DEFAULT NULL,
`contact_name` varchar(50) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`fax` varchar(50) DEFAULT NULL,
`mobile` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`invoice_name` varchar(50) DEFAULT NULL,
`invoice_address` varchar(255) NOT NULL DEFAULT '',
`note` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `day`
--

DROP TABLE IF EXISTS `day`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `day` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`week` int(11) NOT NULL DEFAULT '0',
`day_date` date NOT NULL DEFAULT '0000-00-00',
`start` time NOT NULL DEFAULT '00:00:00',
`end` time NOT NULL DEFAULT '00:00:00',
`lunch_start` time DEFAULT NULL,
`lunch_end` time DEFAULT NULL,
`other_breaks` time DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `week` (`week`),
CONSTRAINT `day_week_fk` FOREIGN KEY (`week`) REFERENCES `week` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5551 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `employee`
--

DROP TABLE IF EXISTS `employee`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `employee` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) NOT NULL DEFAULT '',
`last_name` varchar(50) NOT NULL DEFAULT '',
`title` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice`
--

DROP TABLE IF EXISTS `invoice`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL DEFAULT '0000-00-00',
`customer` int(11) NOT NULL DEFAULT '0',
`contract` int(11) DEFAULT NULL,
`cust_ref` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `invoice_contract_fk` (`contract`),
KEY `invoice_customer_fk` (`customer`),
CONSTRAINT `invoice_contract_fk` FOREIGN KEY (`contract`) REFERENCES `contract` (`id`),
CONSTRAINT `invoice_customer_fk` FOREIGN KEY (`customer`) REFERENCES `customer` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=420 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_line`
--

DROP TABLE IF EXISTS `invoice_line`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_line` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`invoice` int(11) NOT NULL DEFAULT '0',
`line_no` int(11) NOT NULL DEFAULT '0',
`week` int(11) DEFAULT NULL,
`description` varchar(255) NOT NULL DEFAULT '',
`amount` decimal(10,2) NOT NULL DEFAULT '0.00',
`vat` char(10) NOT NULL DEFAULT 'standard',
PRIMARY KEY (`id`),
UNIQUE KEY `alt_key` (`invoice`,`line_no`),
KEY `week` (`week`),
CONSTRAINT `invoice_line_ibfk_1` FOREIGN KEY (`week`) REFERENCES `week` (`id`),
CONSTRAINT `line_invoice_fk` FOREIGN KEY (`invoice`) REFERENCES `invoice` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1134 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `product`
--

DROP TABLE IF EXISTS `product`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `site`
--

DROP TABLE IF EXISTS `site`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `site` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
`address` varchar(50) DEFAULT NULL,
`contact_name` varchar(50) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`fax` varchar(50) DEFAULT NULL,
`mobile` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `vat_rate`
--

DROP TABLE IF EXISTS `vat_rate`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `vat_rate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`start_date` datetime DEFAULT NULL,
`end_date` datetime DEFAULT NULL,
`type` char(10) NOT NULL,
`rate` float NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `week`
--

DROP TABLE IF EXISTS `week`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `week` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`contract` int(11) NOT NULL,
`start` date NOT NULL DEFAULT '0000-00-00',
`invoiced` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `contract` (`contract`),
CONSTRAINT `week_ibfk_1` FOREIGN KEY (`contract`) REFERENCES `contract` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1042 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2015-07-28 10:51:30

0 comments on commit dcce62d

Please sign in to comment.