-- phpMyAdmin SQL Dump
-- version 3.5.3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 04, 2014 at 08:42 AM
-- Server version: 5.5.28
-- PHP Version: 5.4.7

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:  Plastronics2 
--

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

--
-- Table structure for table  customer 
--

CREATE TABLE IF NOT EXISTS  customer  (
   cust_no  int(11) NOT NULL AUTO_INCREMENT,
   name  varchar(40) DEFAULT NULL,
   address  varchar(40) DEFAULT NULL,
   phone  varchar(12) DEFAULT NULL,
  PRIMARY KEY ( cust_no )
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Dumping data for table  customer 
--

INSERT INTO  customer  ( cust_no ,  name ,  address ,  phone ) VALUES
(1, 'Joe Boo', '123 West', '412-773-5322'),
(2, 'Rich Wrack', '332 East', '412-773-8374'),
(3, 'Ken Bend', '225 Main', '412-773-9822'),
(4, 'Kim Slim', '415 Bent', '412-773-6721'),
(5, 'Tom Plom', '633 North', '412-773-4156');

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

--
-- Table structure for table  items 
--

CREATE TABLE IF NOT EXISTS  items  (
   item_no  int(11) NOT NULL AUTO_INCREMENT,
   price  int(11) DEFAULT NULL,
  PRIMARY KEY ( item_no )
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table  items 
--

INSERT INTO  items  ( item_no ,  price ) VALUES
(1, 666),
(2, 700),
(3, 450),
(4, 1200);

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

--
-- Table structure for table  item_details 
--

CREATE TABLE IF NOT EXISTS  item_details  (
   order_no  int(11) NOT NULL,
   item_no  int(11) NOT NULL,
   count  int(11) DEFAULT NULL,
  KEY  FK_order_no  ( order_no ),
  KEY  FK_item_no  ( item_no )
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table  item_details 
--

INSERT INTO  item_details  ( order_no ,  item_no ,  count ) VALUES
(1, 4, 12),
(1, 3, 56),
(2, 1, 10),
(3, 2, 43),
(3, 4, 16),
(4, 2, 87),
(5, 1, 62),
(5, 2, 48),
(5, 3, 5),
(6, 3, 87),
(7, 2, 32),
(7, 1, 27),
(8, 4, 91),
(9, 2, 34),
(9, 3, 72),
(10, 4, 2);

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

--
-- Table structure for table  orders 
--

CREATE TABLE IF NOT EXISTS  orders  (
   order_no  int(11) NOT NULL AUTO_INCREMENT,
   cust_no  int(11) NOT NULL,
  PRIMARY KEY ( order_no ),
  KEY  cust_no  ( cust_no )
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;

--
-- Dumping data for table  orders 
--

INSERT INTO  orders  ( order_no ,  cust_no ) VALUES
(4, 1),
(6, 1),
(5, 2),
(7, 2),
(2, 3),
(8, 3),
(1, 4),
(3, 4),
(9, 4),
(10, 5);

--
-- Constraints for dumped tables
--

--
-- Constraints for table  item_details 
--
ALTER TABLE  item_details 
  ADD CONSTRAINT  item_details_ibfk_1  FOREIGN KEY ( order_no ) REFERENCES  orders  ( order_no ),
  ADD CONSTRAINT  item_details_ibfk_2  FOREIGN KEY ( item_no ) REFERENCES  items  ( item_no );

--
-- Constraints for table  orders 
--
ALTER TABLE  orders 
  ADD CONSTRAINT  orders_ibfk_1  FOREIGN KEY ( cust_no ) REFERENCES  customer  ( cust_no );

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