· 9 years ago · Oct 26, 2016, 11:04 AM
1/*!40101 SET NAMES utf8 */;
2/*!40101 SET SQL_MODE=''*/;
3/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
4/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
5/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
6/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
7CREATE DATABASE /*!32312 IF NOT EXISTS*/`livraria` /*!40100 DEFAULT CHARACTER SET latin1
8*/;
9USE `livraria`;
10/*Table structure for table `autor` */
11DROP TABLE IF EXISTS `autor`;
12CREATE TABLE `autor` (
13 `idautor` int(11) NOT NULL AUTO_INCREMENT,
14 `nome` varchar(100) DEFAULT NULL,
15 `email` varchar(100) DEFAULT NULL,
16 PRIMARY KEY (`idautor`)
17) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
18/*Data for the table `autor` */
19insert into `autor`(`idautor`,`nome`,`email`) values (1,'Roberto Martins
20Figueiredo',NULL),(2,'Daniel Kahneman',NULL),(3,'Hilary Duff',NULL),(4,'Robson
21Pinheiro',NULL),(5,'Cecelia Ahern',NULL),(6,'Arlene Einsenberg',NULL),(7,'Sandee
22Hathaway',NULL),(8,'Heidi Murkoff',NULL),(9,'Julio Cesar de Barros',NULL),(10,'Maria José
23Valero',NULL);
24/*Table structure for table `cliente` */
25DROP TABLE IF EXISTS `cliente`;
26CREATE TABLE `cliente` (
27 `idcliente` int(11) NOT NULL AUTO_INCREMENT,
28 `nome` varchar(100) NOT NULL,
29 `telefone` varchar(45) DEFAULT NULL,
30 PRIMARY KEY (`idcliente`)
31) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
32/*Data for the table `cliente` */
33insert into `cliente`(`idcliente`,`nome`,`telefone`) values (1,'Joao Silva
34','1111'),(2,'Maria Cunha','2222'),(3,'Pedro Aguiar','8888'),(4,'Elaine
35Luciana','9374'),(5,'Antonio Pereira','3764'),(6,'Catarina Dias','999'),(7,'Felipe
36Escolar','8787'),(8,'Nando Caixinha','5478'),(9,'Pelé Golias','7811'),(10,'Tito
37Vardones','7489');
38/*Table structure for table `editora` */
39DROP TABLE IF EXISTS `editora`;
40CREATE TABLE `editora` (
41 `ideditora` int(11) NOT NULL AUTO_INCREMENT,
42 `nome` varchar(100) NOT NULL,
43 `fone` varchar(30) DEFAULT NULL,
44 PRIMARY KEY (`ideditora`)
45) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
46/*Data for the table `editora` */
47insert into `editora`(`ideditora`,`nome`,`fone`) values (1,'Casa dos
48Espiritos',NULL),(2,'Id Editora',NULL),(3,'Objetiva',NULL),(4,'Manole',NULL),(5,'Novo
49Conceito',NULL),(6,'Record',NULL),(7,'Benvirá',NULL),(8,'Scipione',NULL),(9,'Atica',NULL)
50,(10,'Campus',NULL);
51/*Table structure for table `escreve` */
52DROP TABLE IF EXISTS `escreve`;
53CREATE TABLE `escreve` (
54 `idlivro` int(11) NOT NULL,
55 `idautor` int(11) NOT NULL,
56 PRIMARY KEY (`idlivro`,`idautor`),
57 KEY `fk_livro_has_autor_autor1` (`idautor`)
58) ENGINE=MyISAM DEFAULT CHARSET=latin1;
59/*Data for the table `escreve` */
60insert into `escreve`(`idlivro`,`idautor`) values
61(1,1),(2,3),(3,2),(5,5),(6,6),(6,7),(6,8),(7,9),(8,10),(9,10);
62/*Table structure for table `genero` */
63DROP TABLE IF EXISTS `genero`;
64CREATE TABLE `genero` (
65 `idgenero` int(11) NOT NULL AUTO_INCREMENT,
66 `descricao` varchar(100) NOT NULL,
67 PRIMARY KEY (`idgenero`)
68) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
69/*Data for the table `genero` */
70insert into `genero`(`idgenero`,`descricao`) values (1,'Espiritualismo'),(2,'InfantoJuvenil'),(3,'Economia'),(4,'Medicina'),(5,'Romance'),(6,'Historia'),(7,'Fantasia'),(8,'A
71uto-Ajuda'),(9,'Informática'),(10,'Humor');
72/*Table structure for table `itens_da_venda` */
73DROP TABLE IF EXISTS `itens_da_venda`;
74CREATE TABLE `itens_da_venda` (
75 `idvenda` int(11) NOT NULL,
76 `idlivro` int(11) NOT NULL,
77 `qtd` int(11) DEFAULT NULL,
78 `subtotal` varchar(45) DEFAULT NULL,
79 PRIMARY KEY (`idvenda`,`idlivro`),
80 KEY `fk_venda_has_livro_livro1` (`idlivro`)
81) ENGINE=MyISAM DEFAULT CHARSET=latin1;
82/*Data for the table `itens_da_venda` */
83insert into `itens_da_venda`(`idvenda`,`idlivro`,`qtd`,`subtotal`) values
84(1,1,1,NULL),(1,2,1,NULL),(2,2,2,NULL),(2,3,1,NULL),(3,4,1,NULL),(4,5,1,NULL),(5,5,1,NULL
85),(6,5,1,NULL),(7,6,1,NULL),(8,7,2,NULL),(9,8,3,NULL),(10,9,1,NULL),(11,6,1,NULL),(12,1,1
86,NULL),(13,4,1,NULL),(14,7,2,NULL),(15,9,1,NULL),(16,3,1,NULL),(17,8,4,NULL),(18,2,1,NULL
87),(19,4,1,NULL),(20,6,1,NULL);
88/*Table structure for table `livro` */
89DROP TABLE IF EXISTS `livro`;
90CREATE TABLE `livro` (
91 `idlivro` int(11) NOT NULL AUTO_INCREMENT,
92 `titulo` varchar(100) NOT NULL,
93 `preco` float DEFAULT NULL,
94 `estoque` int(11) DEFAULT '0',
95 `idgenero` int(11) NOT NULL,
96 `ideditora` int(11) NOT NULL,
97 PRIMARY KEY (`idlivro`,`idgenero`,`ideditora`),
98 KEY `fk_livro_Genero1` (`idgenero`)
99) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
100/*Data for the table `livro` */
101insert into `livro`(`idlivro`,`titulo`,`preco`,`estoque`,`idgenero`,`ideditora`) values
102(1,'Pelas Ruas de Calcutá',36.1,5,1,1),(2,'Devoted - Devoção',27.2,4,2,2),(3,'Rápido e
103Devagar - Duas Formas de Pensar',43.9,8,3,3),(4,'Xô, Bactéria! Tire Suas Dúvidas Com Dr.
104Bactéria',32.7,6,4,4),(5,'P.s. - Eu Te Amo ',23.5,10,5,5),(6,'O Que Esperar Quando Você
105Está Esperando',37.8,20,4,6),(7,'As Melhores Frases Em Veja',23.9,0,6,7),(8,'Bichos
106Monstruosos',24.9,12,2,6),(9,'Casas Mal Assombradas',27.9,0,2,6);
107/*Table structure for table `venda` */
108DROP TABLE IF EXISTS `venda`;
109CREATE TABLE `venda` (
110 `idvenda` int(11) NOT NULL AUTO_INCREMENT,
111 `data` date DEFAULT NULL,
112 `total` float DEFAULT '0',
113 `idcliente` int(11) NOT NULL,
114 PRIMARY KEY (`idvenda`,`idcliente`),
115 KEY `fk_venda_cliente1` (`idcliente`)
116) ENGINE=MyISAM AUTO_INCREMENT=23 DEFAULT CHARSET=latin1;
117/*Data for the table `venda` */
118insert into `venda`(`idvenda`,`data`,`total`,`idcliente`) values (1,'2012-01-
11901',30,1),(2,'2012-02-02',60,2),(3,'2012-03-03',90,3),(4,'2012-04-04',120,4),(5,'2012-05-
12005',50,5),(6,'2012-06-06',600,6),(7,'2012-07-07',70,7),(8,'2012-08-08',85,8),(9,'2012-09-
12109',100,9),(10,'2012-10-10',35,10),(11,'2012-11-11',99,1),(12,'2012-12-
12212',59,2),(13,'2011-01-02',46,3),(14,'2011-02-01',399,4),(15,'2011-03-
12304',42,5),(16,'2011-04-03',79,6),(17,'2011-05-06',130,7),(18,'2011-06-
12405',245,8),(19,'2011-07-06',19,9),(20,'2011-08-09',14,10);
125/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
126/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
127/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
128/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;