Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.10 KB | None | 0 0
  1. /*exercicio 1*/
  2. create table categorias
  3. (codCategoria integer auto_increment not null,
  4. nome varchar(45) not null,
  5. descricao varchar(45) not null,
  6. PRIMARY KEY(codCategoria));
  7.  
  8. create table Produtos
  9. (codProduto integer auto_increment not null,
  10. codCategoria integer not null,
  11. nome varchar(45) not null,
  12. preco double(4,4) not null,
  13. PRIMARY KEY(codProduto),
  14. FOREIGN KEY (codCategoria) references categorias(codCategoria));
  15.  
  16. create table Clientes
  17. (codCliente integer auto_increment not null,
  18. nome varchar(45) not null,
  19. telefone varchar(45) not null,
  20. limiteCredito double (4,0) not null,
  21. PRIMARY KEY(codCliente));
  22.  
  23. create table Pedidos
  24. (numPedido integer auto_increment not null,
  25. codCliente integer not null,
  26. data date not null,
  27. PRIMARY KEY(numPedido),
  28. foreign key (codCliente) references clientes(codCliente));
  29.  
  30. create table ProdutoPedido
  31. (numPedido integer not null,
  32. codCliente integer not null,
  33. dataa date not null,
  34. quantidade integer not null,
  35. PRIMARY KEY(codCliente, numPedido),
  36. foreign key(codCliente) references clientes(codCliente),
  37. foreign key(numPedido) references pedidos(codCliente));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement