Banco inconsistente

0 respostas
Mariana.Vecci

Olá amiguinhos! bom, a algum tempo eu fiz um trabalho que consistia em uma loja, mas deixei o banco limitado a um produto por pedido, e agora quero mudar isso,
fiz algumas mudanças no sql, mas não sei se ficou certo, obrigada!

CREATE TABLE Cliente (
  codc integer PRIMARY KEY,
  nomec varchar(30) not null,
  fonec varchar(10) not null
);

CREATE TABLE Videogame (
  codvg integer PRIMARY KEY,
  modelovg varchar(15) not null,
  precovg float not null,
  qtdvg int not null
);

CREATE TABLE Login (
  nome varchar(30) not null,
  senha varchar (10) not null
); 

CREATE TABLE Pedido (
  codp integer PRIMARY KEY,
  FKcodc integer,
  FKcodvg integer,
  FOREIGN KEY(FKcodc) REFERENCES Cliente (codc),
  FOREIGN KEY(FKcodvg) REFERENCES Videogame (codvg)
);

CREATE TABLE ItemPedido (
  FKcodvnd integer,
  FKcodvg integer, 
  qtdcomprada integer not null,
  valorunt float not null,
  FOREIGN KEY(FKcodvg) REFERENCES Videogame (codvg),
  FOREIGN KEY(FKcodvnd) REFERENCES Venda (codvnd), 
);

CREATE TABLE Venda (
  codvnd integer PRIMARY KEY,
  FKcodc integer,
  datavnd date not null,
  valortotal float not null,
  FOREIGN KEY(FKcodc) REFERENCES Cliente (codc),
);
Criado 18 de março de 2011
Respostas 0
Participantes 1