Skip to content

Instantly share code, notes, and snippets.

@diogomatheus
Created May 12, 2011 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogomatheus/967767 to your computer and use it in GitHub Desktop.
Save diogomatheus/967767 to your computer and use it in GitHub Desktop.
Script order database
--
-- Banco de Dados: `zf-order`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `order`
--
CREATE TABLE IF NOT EXISTS `order` (
`order_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`order_id`),
KEY `request_FKIndex1` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Extraindo dados da tabela `order`
--
INSERT INTO `order` (`order_id`, `user_id`, `create_date`) VALUES
(1, 2, '2011-05-07 02:25:12'),
(2, 3, '2011-05-07 02:25:12');
-- --------------------------------------------------------
--
-- Estrutura da tabela `order_item`
--
CREATE TABLE IF NOT EXISTS `order_item` (
`order_id` bigint(20) unsigned NOT NULL,
`product_id` bigint(20) NOT NULL,
`amount` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`order_id`,`product_id`),
KEY `request_has_product_FKIndex1` (`order_id`),
KEY `request_has_product_FKIndex2` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `order_item`
--
INSERT INTO `order_item` (`order_id`, `product_id`, `amount`) VALUES
(1, 1, 1),
(1, 2, 2),
(2, 3, 1),
(2, 4, 1);
-- --------------------------------------------------------
--
-- Estrutura da tabela `product`
--
CREATE TABLE IF NOT EXISTS `product` (
`product_id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`name` varchar(100) NOT NULL,
`value` decimal(10,2) NOT NULL,
PRIMARY KEY (`product_id`),
KEY `product_FKIndex1` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Extraindo dados da tabela `product`
--
INSERT INTO `product` (`product_id`, `user_id`, `name`, `value`) VALUES
(1, 1, 'Camisa simples', 15.00),
(2, 1, 'Camisa estampada', 25.00),
(3, 1, 'Bermuda', 40.00),
(4, 2, 'Casaco', 60.00);
-- --------------------------------------------------------
--
-- Estrutura da tabela `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`user_id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`email` varchar(100) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Extraindo dados da tabela `user`
--
INSERT INTO `user` (`user_id`, `name`, `email`) VALUES
(1, 'Diogo Matheus', 'dm.matheus@gmail.com'),
(2, 'Claudio', 'claudio@gmail.com'),
(3, 'Thiago', 'thiago@gmail.com');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment