Está en la página 1de 9

UNIVERSIDAD PRIVADA ANTENOR ORREGO

FACULTAD DE INGENIERÍA
ESCUELA PROFESIONAL DE INGENIERÍA
INDUSTRIAL
Computación en Ingeniería – T1 – Nrc 12330

INFORME II
“Tarea Grupal Práctica MySQL”

DOCENTE:
- Chimoy Asto Guillermo Enrique

INTEGRANTES:
- Blas Cueva Fabrizio Eduardo Alonso
- Loli Cassinelli Estefano Eduardo

FECHA DE PRESENTACIÓN: viernes 10 de diciembre

TRUJILLO – PERÚ

2022
Trabajo
Grupal

Se le encomienda crear una base de datos que permita registrar las ventas que realiza
laempresa en la cual labora bajo las siguientes condiciones:

a) Las tablas son:

b) Se establece las siguientes relaciones


 Un cliente puede tener varios pedidos
 Un vendedor puede atender varios pedidos
 Un pedido puede tener varios Detalle de pedido
 Un producto puede tener varios Detalles de pedido
c) Complementar
3.1 Definir el tipo de datos para cada campo
3.2 Definir los campos que pueden contener valor nulo
3.3 Evaluar si se requiere Primary Key e indicar que tablas las requieren

Se solicita:

1 Implementar la Base de Datos según las condiciones indicadas en los ítem a) y


b)y las definiciones y evaluaciones que Uds han realizado en el ítem c).
2 Generar el Diagrama de Bases de Datos
3 Sustentar las definiciones realizadas en el ítem c)
4 Insertar por lo menos 5 registros en cada tabla
5 Realizar las siguientes instrucciones:
a. Listar los clientes que el subtotal de pedido sea mayor a 1,000.00
b. Listar los clientes que registran el país de Perú
c. Listar los pedidos realizados por los clientes que se registran en la ciudad
deTrujillo
d. Indicar cuantos pedidos han sido atendidos por el vendedor que tiene
sunombre que empieza con “J”
e. Actualizar el dato ciudad del cliente con ID_codigo C003 por la ciudad
deIquitos.

Entregable a generar:

- Un documento conteniendo la explicación y solución de lo solicitado


- Exposición en clase
DESARROLLO:

- Código:
--
-- Table structure for table `articulo`
--
CREATE TABLE `articulo` (
`id` int(11) NOT NULL,
`descripcion` text DEFAULT NULL,
`precio_unitario` decimal(10,2) DEFAULT NULL,
`stock` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
--
-- Dumping data for table `articulo`
--
INSERT INTO `articulo` (`id`, `descripcion`, `precio_unitario`, `stock`) VALUES
(1000, 'Nokia 1231', '500.00', 5),
(1478, 'Xiami 10 pro', '100.00', 5),
(1479, 'Motorla 10i', '150.00', 3),
(8585, 'iphone 14 pro', '320.00', 2),
(8586, 'Samsung s22+', '300.00', 1),
(8587, 'Motorola FLip', '400.00', 9);
-- --------------------------------------------------------
--
-- Table structure for table `cliente`
--
CREATE TABLE `cliente` (
`id` int(11) NOT NULL,
`nombres` varchar(100) DEFAULT NULL,
`apellido_paterno` varchar(100) DEFAULT NULL,
`apellido_materno` varchar(100) DEFAULT NULL,
`direccion` varchar(100) DEFAULT NULL,
`ciudad` varchar(100) DEFAULT NULL,
`pais` varchar(100) DEFAULT NULL,
`celular` varchar(20) DEFAULT NULL,
`fax` varchar(20) DEFAULT NULL,
`fecha_ingreso` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE
current_timestamp(),
`ind_vigente` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
--
-- Dumping data for table `cliente`
--
INSERT INTO `cliente` (`id`, `nombres`, `apellido_paterno`, `apellido_materno`, `direccion`,
`ciudad`, `pais`, `celular`, `fax`, `fecha_ingreso`, `ind_vigente`) VALUES
(1000, 'Remo', 'Calegari', 'Ramos', 'Las flores de huanchaco800', 'Iquitos', 'Perú', '55145',
'5454541', '2022-12-11 02:25:38', '80'),
(1478, 'Giacomo', 'Roeder', 'Sanchez', 'Colins av 4109', 'Miami', 'EEUU', '545645', '5466541',
'2022-12-11 02:11:46', '50'),
(1479, 'Juan', 'Perez', 'Aguilar', 'Las flores 363', 'Trujillo', 'Perú', '989895689', '224548', '2022-
12-11 02:03:31', '70'),
(8586, 'Maximo', 'Ride ', 'Lite', 'Miraflores ', 'Lima', 'Perú', '202020', '0210230', '2022-12-11
02:13:24', '90'),
(14799, 'Bryan', 'Yarrow', 'Zambrano', 'Mz. E559552 lt12', 'Trujillo', 'Perú', '212030',
'165615213', '2022-12-11 02:14:06', '90'),
(14800, 'Jose', 'Lopez', 'Nuñez', 'Dirección 111', 'Trujillo', 'Perú', '985748965', '248596', '2022-
12-11 02:04:06', '80');
-- --------------------------------------------------------
--
-- Table structure for table `detalle_pedido`
--
CREATE TABLE `detalle_pedido` (
`id` int(11) NOT NULL,
`id_articulo` int(11) DEFAULT NULL,
`cantidad` int(11) DEFAULT NULL,
`precio` decimal(10,2) DEFAULT NULL,
`subtotal` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
--
-- Dumping data for table `detalle_pedido`
--
INSERT INTO `detalle_pedido` (`id`, `id_articulo`, `cantidad`, `precio`, `subtotal`) VALUES
(1, 1000, 2, '500.00', '1000.00'),
(3, 1478, 3, '100.00', '300.00'),
(4, 8586, 1, '300.00', '300.00'),
(5, 1478, 3, '100.00', '300.00'),
(6, 8586, 1, '300.00', '300.00'),
(7, 8587, 7, '400.00', '3600.00'),
(8, 8587, 7, '400.00', '3600.00');
-- --------------------------------------------------------
--
-- Table structure for table `pedido`
--
CREATE TABLE `pedido` (
`id` int(11) NOT NULL,
`id_cliente` int(11) DEFAULT NULL,
`id_vendedor` int(11) DEFAULT NULL,
`fecha_pedido` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE
current_timestamp(),
`subtotal` decimal(10,2) DEFAULT NULL,
`impuesto` decimal(10,2) DEFAULT NULL,
`total` decimal(10,2) DEFAULT NULL,
`estado` tinyint(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
--
-- Dumping data for table `pedido`
--
INSERT INTO `pedido` (`id`, `id_cliente`, `id_vendedor`, `fecha_pedido`, `subtotal`, `impuesto`,
`total`, `estado`) VALUES
(1000, 1000, 2, '2022-12-11 02:17:51', '1000.00', '18.00', '518.00', 70),
(1471, 14799, 60, '2022-12-24 02:06:02', '500.00', '18.00', '518.00', 80),
(1478, 14800, 2, '2022-12-11 02:17:54', '300.00', '18.00', '318.00', 100),
(1479, 14800, 70, '2022-12-18 02:05:23', '3600.00', '18.00', '3618.00', 100),
(8587, 8586, 40, '2022-12-15 02:06:02', '9000.00', '18.00', '9018.00', 100);
-- --------------------------------------------------------
--
-- Table structure for table `vendedor`
--
CREATE TABLE `vendedor` (
`id` int(11) NOT NULL,
`nombre` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
--
-- Dumping data for table `vendedor`
--
INSERT INTO `vendedor` (`id`, `nombre`) VALUES
(1, 'Otto'),
(2, 'Juan '),
(3, 'Pablo'),
(4, 'Jose '),
(5, 'Giacomo'),
(6, 'Jorge'),
(7, 'Carlitos'),
(8, 'Ismael'),
(9, 'Gabriel'),
(10, 'Armando');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `articulo`
--
ALTER TABLE `articulo`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cliente`
--
ALTER TABLE `cliente`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `detalle_pedido`
--
ALTER TABLE `detalle_pedido`
ADD PRIMARY KEY (`id`),
ADD KEY `fk_detalle_pedido_articulo` (`id_articulo`);
--
-- Indexes for table `pedido`
--
ALTER TABLE `pedido`
ADD PRIMARY KEY (`id`),
ADD KEY `fk_pedido_cliente` (`id_cliente`);
--
-- Indexes for table `vendedor`
--
ALTER TABLE `vendedor`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `articulo`
--
ALTER TABLE `articulo`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8588;
--
-- AUTO_INCREMENT for table `cliente`
--
ALTER TABLE `cliente`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14801;
--
-- AUTO_INCREMENT for table `detalle_pedido`
--
ALTER TABLE `detalle_pedido`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `pedido`
--
ALTER TABLE `pedido`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8588;
--
-- AUTO_INCREMENT for table `vendedor`
--
ALTER TABLE `vendedor`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `detalle_pedido`
--
ALTER TABLE `detalle_pedido`
ADD CONSTRAINT `fk_detalle_pedido_articulo` FOREIGN KEY (`id_articulo`) REFERENCES
`articulo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `pedido`
--
ALTER TABLE `pedido`
ADD CONSTRAINT `fk_pedido_cliente` FOREIGN KEY (`id_cliente`) REFERENCES `cliente` (`id`)
ON DELETE NO ACTION ON UPDATE NO ACTION;
COMMIT;
- Captura de Pantalla:

- Realiza las siguientes instrucciones:

a) Listar los clientes que el subtotal de pedido sea mayor a 1,000.00


SELECT * FROM cliente AS c INNER JOIN pedido AS p ON c.id = p.id_cliente
WHERE p.subtotal > 1000

b) Listar los clientes que registran el país de Perú


SELECT * FROM cliente AS c WHERE c.pais = 'Perú'

c) Listar los pedidos realizados por los clientes que se registran en la ciudad de
Trujillo

SELECT * FROM cliente AS c INNER JOIN pedido AS p ON c.id = p.id_cliente


WHERE c.ciudad = 'Trujillo'

d) Indicar cuantos pedidos han sido atendidos por el vendedor que tiene su nombre
que empieza con “J”
SELECT COUNT(*) FROM pedido AS p INNER JOIN vendedor AS v ON v.id =
p.id_vendedor WHERE v.nombre LIKE 'J%'

e) Actualizar el dato ciudad del cliente con ID 1000 por la ciudad de Iquitos.
UPDATE cliente SET ciudad = 'Iquitos' WHERE id = 1000

También podría gustarte