Está en la página 1de 2

use helados;

create table cliente(


idCliente int not null PRIMARY KEY AUTO_INCREMENT,
nombreCliente varchar(30) not null,
apellidoCliente varchar(30) not null,
dni varchar(10) not null,
direccion varchar(30),
departamento varchar(30) not null,
provincia varchar(30) not null,
distrito varchar(30) not null,
telefono int ,
correo varchar(50)
);

create table adicional(


idAdicional int not null PRIMARY KEY AUTO_INCREMENT,
nombreAdicional varchar(30) not null,
precioUnitario decimal(4,2) not null,
cantidad int not null,
precioTotal decimal(4,2) not null
);

create table organizacion(


idOrganizacion int not null PRIMARY KEY AUTO_INCREMENT,
nombreOrganizacion varchar(30) not null,
direccion varchar(30) not null,
departamento varchar(30) not null,
provincia varchar(30) not null,
distrito varchar(30) not null
);

create table usuario(


idUsuario int not null PRIMARY KEY AUTO_INCREMENT,
nombreUsuario varchar(30) not null ,
apellidoUsuario varchar(30) not null,
nickName varchar(30) not null,
correo varchar(30) not null,
password varchar(30) not null
);

create table categoria(


idCategoria int not null PRIMARY KEY AUTO_INCREMENT,
nombreCategoria varchar(30) not null
);

create table presentacion(


idPresentacion int not null PRIMARY KEY AUTO_INCREMENT,
nombrePresentacion varchar(30) not null
);

create table Producto(


idProducto int not null PRIMARY KEY AUTO_INCREMENT,
idCategoria int not null,
idPresentacion int not null,
nombreProducto varchar(30) not null,
cantidadSabores int,
precio decimal(4,2) not null,
FOREIGN KEY (idCategoria) REFERENCES Categoria(idCategoria),
FOREIGN KEY (idPresentacion) REFERENCES Presentacion(idPresentacion)
);
create table tipo(
idTipo int not null PRIMARY KEY AUTO_INCREMENT,
nombreTipo varchar(30) not null
);

create table sabor(


idSabor int not null PRIMARY KEY AUTO_INCREMENT,
nombreSabor varchar(30) not null,
idTipo int not null,
FOREIGN KEY (idTipo) REFERENCES Tipo(idTipo)
);
create table venta(
idVenta int not null PRIMARY KEY AUTO_INCREMENT,
idCliente int not null,
fecha date not null,
idOrganizacion int not null,
precioEnvio decimal(4,2) not null,
subtotal decimal (4,2) not null,
igv decimal (4,2) not null,
total decimal (4,2) not null,
FOREIGN KEY (idCliente) REFERENCES Cliente(idCliente),
FOREIGN KEY (idOrganizacion) REFERENCES Organizacion(idOrganizacion)
);

create table detalleVenta(


idDetalleVenta int not null PRIMARY KEY AUTO_INCREMENT,
idProducto int not null,
idVenta int not null,
idAdicional int not null,
cantidad int not null,
descuento decimal(4,2) ,
precioVenta decimal (4,2),
FOREIGN KEY (idProducto) REFERENCES Producto(idProducto),
FOREIGN KEY (idVenta) REFERENCES Venta(idVenta),
FOREIGN KEY (idAdicional) REFERENCES Adicional(idAdicional)
);

create table saboresPedido(


idSaboresPedido int not null PRIMARY KEY AUTO_INCREMENT,
idDetalleVenta int not null,
idSabor int not null,
FOREIGN KEY (idDetalleVenta) REFERENCES DetalleVenta(idDetalleVenta),
FOREIGN KEY (idSabor) REFERENCES Sabor(idSabor)
);

También podría gustarte