You are on page 1of 6

db_sales script

-- phpMyAdmin SQL Dump


-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 02, 2016 at 04:13 AM
-- Server version: 5.5.8
-- PHP Version: 5.3.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

/*!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: `db_sales`
--

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

--
-- Table structure for table `barcode`
--

CREATE TABLE IF NOT EXISTS `barcode` (


`barcode_ean` char(13) NOT NULL,
`item_id` int(11) NOT NULL,
PRIMARY KEY (`barcode_ean`),
KEY `barcode_item_id_fk` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `barcode`
--

INSERT INTO `barcode` (`barcode_ean`, `item_id`) VALUES


('6241527836173', 1),
('6241574635234', 2),
('6241527746363', 3),
('6264537836173', 3),
('7465743843764', 4),
('3453458677628', 5),
('6434564564544', 6),
('8476736836876', 7),
('6241234586487', 8),
('9473625532534', 8),
('9473627464543', 8),
('4587263646878', 9),
('2239872376872', 11),
('9879879837489', 11);

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

--
-- Table structure for table `categories`
--

CREATE TABLE IF NOT EXISTS `categories` (


`Category_id` int(11) NOT NULL AUTO_INCREMENT,
`CategoryName` varchar(15) NOT NULL,
`Description` mediumtext,
PRIMARY KEY (`Category_id`),
KEY `CategoryName` (`CategoryName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`Category_id`, `CategoryName`, `Description`) VALUES


(1, 'appliances', 'home furniture'),
(2, 'decor', 'home decorations'),
(3, 'miscellaneous', 'at iba pa'),
(4, 'electronics', 'electronic equipment'),
(5, 'playthings', 'playable items'),
(6, 'necessities', 'peronal effects');

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

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

CREATE TABLE IF NOT EXISTS `customer` (


`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`title` char(4) DEFAULT NULL,
`fname` varchar(32) DEFAULT NULL,
`lname` varchar(32) NOT NULL,
`addressline` varchar(64) DEFAULT NULL,
`town` varchar(32) DEFAULT NULL,
`zipcode` char(10) NOT NULL,
`phone` varchar(16) DEFAULT NULL,
`creditlimit` int(11) NOT NULL,
`level` varchar(16) NOT NULL,
PRIMARY KEY (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=24 ;

--
-- Dumping data for table `customer`
--

INSERT INTO `customer` (`customer_id`, `title`, `fname`, `lname`, `addressline`,


`town`, `zipcode`, `phone`, `creditlimit`, `level`) VALUES
(2, 'Mr', 'Andrew', 'Stones', '52 The Willows', 'Lowtown', 'LT5 7RA', '876 3527',
20000, 'GOLD'),
(3, 'Miss', 'Alex', 'Matthew', '4 The Street', 'Nicetown', 'NT2 2TX', '010 4567',
50000, 'GOLD'),
(4, 'Mr', 'Adrian', 'Matthew', 'The Barn', 'Yuleville', 'YV67 2WR', '487 3871',
50000, 'GOLD'),
(5, 'Mr', 'Simon', 'Cozens', '7 Shady Lane', 'Oakenham', 'OA3 6QW', '514 5926',
75000, 'PLATINUM'),
(6, 'Mr', 'Neil', 'Matthew', '5 Pasture Lane', 'Nicetown', 'NT3 7RT', '267 1232',
75000, 'GOLD'),
(7, 'Mr', 'Richard', 'Stones', '34 Holly Way', 'Bingham', 'BG4 2WE', '342 5982',
20000, 'GOLD'),
(8, 'Mrs', 'Ann', 'Stones', '34 Holly Way', 'Bingham', 'BG4 2WE', '342 5982',
20000, 'GOLD'),
(9, 'Mrs', 'Christine', 'Hickman', '36 Queen Street', 'Histon', 'HT3 5EM', '342
5432', 20000, 'GOLD'),
(10, 'Mr', 'Mike', 'Howard', '86 Dysart Street', 'Tibsville', 'TB3 7FG', '505
5482', 5000, 'SILVER'),
(11, 'Mr', 'Dave', 'Jones', '54 Vale Rise', 'Bingham', 'BG3 8GD', '342 8264', 5000,
'GOLD'),
(12, 'Mr', 'Richard', 'Neill', '42 Thatched Way', 'Winnersby', 'WB3 6GQ', '505
6482', 0, 'GOLD'),
(13, 'Mrs', 'Laura', 'Hardy', '73 Margarita Way', 'Oxbridge', 'OX2 3HX', '821
2335', 0, 'GOLD'),
(14, 'Mr', 'Bill', 'O''Neill', '2 Beamer Street', 'Welltown', 'WT3 8GM', '435
1234', 0, 'GOLD'),
(17, 'mr', 'John', 'Doe', 'bicutan', 'taguig city', '1630', '091044444', 0, ''),
(18, 'mrs', 'aaa', 'bbb', 'alabang', 'muntinlupa city', '1631', '0913445667', 0,
''),
(19, 'mrs', 'aaa', 'bbb', 'alabang', 'muntinlupa city', '1631', '0913445667',
10000, 'gold'),
(20, 'mrs', 'xxx', 'zzz', 'alabang', 'muntinlupa city', '1631', '0913445667',
10000, 'gold'),
(21, 'mrs', 'yyy', 'qqq', 'alabang', 'muntinlupa city', '1631', '0913445667',
10000, 'gold'),
(22, 'mr', 'Johnny', 'Doer', 'bicutan', 'taguig city', '1630', '091044444', 10000,
'gold'),
(23, 'mrs', 'yyy', 'qqq', 'alabang', 'muntinlupa city', '1631', '0913445667',
10000, 'gold');

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

--
-- Table structure for table `item`
--

CREATE TABLE IF NOT EXISTS `item` (


`item_id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(64) NOT NULL,
`cost_price` decimal(7,2) DEFAULT NULL,
`sell_price` decimal(7,2) DEFAULT NULL,
`discontinued` bit(1) NOT NULL,
`category_id` int(8) NOT NULL,
PRIMARY KEY (`item_id`),
KEY `category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;

--
-- Dumping data for table `item`
--

INSERT INTO `item` (`item_id`, `description`, `cost_price`, `sell_price`,


`discontinued`, `category_id`) VALUES
(1, 'Wood Puzzle', 15.23, 21.95, '1', 5),
(2, 'Rubik Cube', 7.45, 11.49, '0', 5),
(3, 'Linux CD', 1.99, 2.49, '0', 3),
(4, 'Tissues', 2.11, 3.99, '0', 6),
(5, 'Picture Frame', 7.54, 9.95, '0', 2),
(6, 'Fan Small', 9.23, 15.75, '0', 1),
(7, 'Fan Large', 13.36, 19.95, '0', 1),
(8, 'Toothbrush', 0.75, 1.45, '0', 6),
(9, 'Roman Coin', 2.34, 2.45, '0', 2),
(10, 'Carrier Bag', 0.01, 0.00, '0', 6),
(11, 'Speakers', 19.73, 25.32, '1', 4);

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

--
-- Table structure for table `orderinfo`
--

CREATE TABLE IF NOT EXISTS `orderinfo` (


`orderinfo_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`date_placed` date NOT NULL,
`date_shipped` date DEFAULT NULL,
`shipping` decimal(7,2) DEFAULT NULL,
`shipvia` int(11) NOT NULL,
`status` varchar(11) NOT NULL DEFAULT 'not shipped',
PRIMARY KEY (`orderinfo_id`),
KEY `orderinfo_customer_id_fk` (`customer_id`),
KEY `shipper_id` (`shipvia`),
KEY `shipper_id_2` (`shipvia`),
KEY `shipvia` (`shipvia`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;

--
-- Dumping data for table `orderinfo`
--

INSERT INTO `orderinfo` (`orderinfo_id`, `customer_id`, `date_placed`,


`date_shipped`, `shipping`, `shipvia`, `status`) VALUES
(1, 3, '2015-07-02', '2015-07-02', 2.99, 1, 'shipped'),
(2, 8, '2015-07-10', '2015-07-17', 0.00, 1, 'cancelled'),
(4, 13, '2015-07-18', '2015-07-18', 2.99, 2, 'shipped'),
(5, 8, '2015-07-02', '2015-07-02', 0.00, 3, 'shipped'),
(10, 10, '2015-07-30', '2015-08-01', 7.50, 1, 'not shipped'),
(11, 10, '2015-07-30', '2015-08-01', 7.50, 1, 'not shipped');

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

--
-- Table structure for table `orderline`
--

CREATE TABLE IF NOT EXISTS `orderline` (


`orderinfo_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
PRIMARY KEY (`orderinfo_id`,`item_id`),
KEY `orderline_item_id_fk` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `orderline`
--

INSERT INTO `orderline` (`orderinfo_id`, `item_id`, `quantity`) VALUES


(1, 4, 1),
(1, 7, 1),
(1, 9, 1),
(2, 1, 1),
(2, 4, 2),
(2, 7, 2),
(2, 10, 1),
(4, 5, 2),
(5, 1, 1),
(5, 3, 1),
(10, 3, 5),
(10, 6, 3);

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

--
-- Table structure for table `shippers`
--

CREATE TABLE IF NOT EXISTS `shippers` (


`Shipper_id` int(11) NOT NULL AUTO_INCREMENT,
`CompanyName` varchar(40) NOT NULL,
`Phone` varchar(24) DEFAULT NULL,
PRIMARY KEY (`Shipper_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--
-- Dumping data for table `shippers`
--

INSERT INTO `shippers` (`Shipper_id`, `CompanyName`, `Phone`) VALUES


(1, 'LBC Express', '(02) 838-9889'),
(2, 'door to door express', '(503) 555-3199'),
(3, 'FEDEX', '(503) 555-9931');

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

--
-- Table structure for table `stock`
--

CREATE TABLE IF NOT EXISTS `stock` (


`item_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
PRIMARY KEY (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `stock`
--

INSERT INTO `stock` (`item_id`, `quantity`) VALUES


(1, 12),
(2, 2),
(4, 8),
(5, 3),
(7, 8),
(8, 18),
(10, 1);
--
-- Constraints for dumped tables
--

--
-- Constraints for table `barcode`
--
ALTER TABLE `barcode`
ADD CONSTRAINT `barcode_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`
(`item_id`);

--
-- Constraints for table `item`
--
ALTER TABLE `item`
ADD CONSTRAINT `category_fk` FOREIGN KEY (`category_id`) REFERENCES `categories`
(`Category_id`) ON DELETE CASCADE ON UPDATE NO ACTION;

--
-- Constraints for table `orderinfo`
--
ALTER TABLE `orderinfo`
ADD CONSTRAINT `orderinfo_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customer`
(`customer_id`) ON DELETE CASCADE,
ADD CONSTRAINT `orderinfo_shipper_id_fk` FOREIGN KEY (`shipvia`) REFERENCES
`shippers` (`Shipper_id`);

--
-- Constraints for table `orderline`
--
ALTER TABLE `orderline`
ADD CONSTRAINT `orderline_ibfk_2` FOREIGN KEY (`orderinfo_id`) REFERENCES
`orderinfo` (`orderinfo_id`) ON DELETE CASCADE,
ADD CONSTRAINT `orderline_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `item`
(`item_id`) ON DELETE NO ACTION;

--
-- Constraints for table `stock`
--
ALTER TABLE `stock`
ADD CONSTRAINT `stock_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`
(`item_id`);

You might also like