-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_bd.sql
35 lines (35 loc) · 1.29 KB
/
script_bd.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
CREATE DATABASE `ecommerce_schema` /*!40100 DEFAULT CHARACTER SET utf8 */;
CREATE TABLE `categoria` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(40) DEFAULT NULL,
`descricao` varchar(40) DEFAULT NULL,
`categoria_pai_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `categoria_pai_id` (`categoria_pai_id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
CREATE TABLE `item_pedido` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pedido_id` int(11) DEFAULT NULL,
`produto_id` int(11) DEFAULT NULL,
`quantidade` int(11) DEFAULT NULL,
`preco` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
CREATE TABLE `pedido` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`total` double DEFAULT NULL,
`usuario_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
CREATE TABLE `produto` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(200) DEFAULT NULL,
`descricao` varchar(1000) DEFAULT NULL,
`preco` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
CREATE TABLE `produto_possui_categoria` (
`produto_id` int(11) NOT NULL,
`categoria_id` int(11) NOT NULL,
PRIMARY KEY (`produto_id`,`categoria_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;