· 8 years ago · Jul 30, 2018, 07:54 AM
1--
2-- Banco de Dados: `zf-order`
3--
4
5-- --------------------------------------------------------
6
7--
8-- Estrutura da tabela `order`
9--
10
11CREATE TABLE IF NOT EXISTS `order` (
12 `order_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
13 `user_id` bigint(20) NOT NULL,
14 `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
15 PRIMARY KEY (`order_id`),
16 KEY `request_FKIndex1` (`user_id`)
17) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
18
19--
20-- Extraindo dados da tabela `order`
21--
22
23INSERT INTO `order` (`order_id`, `user_id`, `create_date`) VALUES
24(1, 2, '2011-05-07 02:25:12'),
25(2, 3, '2011-05-07 02:25:12');
26
27-- --------------------------------------------------------
28
29--
30-- Estrutura da tabela `order_item`
31--
32
33CREATE TABLE IF NOT EXISTS `order_item` (
34 `order_id` bigint(20) unsigned NOT NULL,
35 `product_id` bigint(20) NOT NULL,
36 `amount` int(10) unsigned DEFAULT NULL,
37 PRIMARY KEY (`order_id`,`product_id`),
38 KEY `request_has_product_FKIndex1` (`order_id`),
39 KEY `request_has_product_FKIndex2` (`product_id`)
40) ENGINE=InnoDB DEFAULT CHARSET=latin1;
41
42--
43-- Extraindo dados da tabela `order_item`
44--
45
46INSERT INTO `order_item` (`order_id`, `product_id`, `amount`) VALUES
47(1, 1, 1),
48(1, 2, 2),
49(2, 3, 1),
50(2, 4, 1);
51
52-- --------------------------------------------------------
53
54--
55-- Estrutura da tabela `product`
56--
57
58CREATE TABLE IF NOT EXISTS `product` (
59 `product_id` bigint(20) NOT NULL AUTO_INCREMENT,
60 `user_id` bigint(20) NOT NULL,
61 `name` varchar(100) NOT NULL,
62 `value` decimal(10,2) NOT NULL,
63 PRIMARY KEY (`product_id`),
64 KEY `product_FKIndex1` (`user_id`)
65) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
66
67--
68-- Extraindo dados da tabela `product`
69--
70
71INSERT INTO `product` (`product_id`, `user_id`, `name`, `value`) VALUES
72(1, 1, 'Camisa simples', 15.00),
73(2, 1, 'Camisa estampada', 25.00),
74(3, 1, 'Bermuda', 40.00),
75(4, 2, 'Casaco', 60.00);
76
77-- --------------------------------------------------------
78
79--
80-- Estrutura da tabela `user`
81--
82
83CREATE TABLE IF NOT EXISTS `user` (
84 `user_id` bigint(20) NOT NULL AUTO_INCREMENT,
85 `name` varchar(50) DEFAULT NULL,
86 `email` varchar(100) NOT NULL,
87 PRIMARY KEY (`user_id`)
88) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
89
90--
91-- Extraindo dados da tabela `user`
92--
93
94INSERT INTO `user` (`user_id`, `name`, `email`) VALUES
95(1, 'Diogo Matheus', 'dm.matheus@gmail.com'),
96(2, 'Claudio', 'claudio@gmail.com'),
97(3, 'Thiago', 'thiago@gmail.com');