MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | bd_biblioteca | | information_schema | | inventario | | libreria | | libro | | matricula | | matricula1 | | matricula2 | | mysql | | otros | | performance_schema | | phpmyadmin | | subconsultas | | test | | turismo | +--------------------+ 15 rows in set (0.053 sec) MariaDB [(none)]> use inventario; Database changed MariaDB [inventario]> describe producto; +--------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+-------+ | id_producto | varchar(20) | NO | PRI | NULL | | | Nombre | varchar(45) | NO | | NULL | | | Precio_costo | int(45) | NO | | NULL | | | Precio_venta | int(45) | NO | | NULL | | | Disponible | int(45) | NO | | NULL | | +--------------+-------------+------+-----+---------+-------+ 5 rows in set (0.032 sec) MariaDB [inventario]> describe proveedores; +--------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+-------+ | id_proveedor | varchar(20) | NO | PRI | NULL | | | Nombre | varchar(45) | NO | | NULL | | | Telefono | varchar(45) | NO | | NULL | | | Ciudad | varchar(45) | NO | | NULL | | +--------------+-------------+------+-----+---------+-------+ 4 rows in set (0.032 sec) MariaDB [inventario]> describe Cliente; +------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+-------+ | id_cliente | varchar(20) | NO | PRI | NULL | | | Nombre | varchar(45) | NO | | NULL | | | Telefono | varchar(45) | NO | | NULL | | | Ciudad | varchar(45) | NO | | NULL | | +------------+-------------+------+-----+---------+-------+ 4 rows in set (0.021 sec) MariaDB [inventario]> describe Pedidos_Proveedores; +----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+---------+-------+ | id_pedidoProve | varchar(20) | NO | PRI | NULL | | | Fecha | varchar(45) | NO | | NULL | | | FK_proveedor | varchar(20) | NO | MUL | NULL | | +----------------+-------------+------+-----+---------+-------+ 3 rows in set (0.022 sec) MariaDB [inventario]> describe Detalles_Pedido; +-----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+-------+ | id_detallePedi | varchar(20) | NO | PRI | NULL | | | camtidad_pedido | int(45) | NO | | NULL | | | Precio_compra | int(45) | NO | | NULL | | | FK_pedidoProve | varchar(20) | NO | MUL | NULL | | | FK_produto | varchar(20) | NO | MUL | NULL | | +-----------------+-------------+------+-----+---------+-------+ 5 rows in set (0.031 sec) MariaDB [inventario]> describe venta; +------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+-------+ | id_venta | varchar(20) | NO | PRI | NULL | | | Fecha | varchar(45) | NO | | NULL | | | FK_cliente | varchar(20) | NO | MUL | NULL | | +------------+-------------+------+-----+---------+-------+ 3 rows in set (0.022 sec) MariaDB [inventario]> describe Detalles_Venta; +------------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+-------------+------+-----+---------+-------+ | id_detalleVent | varchar(20) | NO | PRI | NULL | | | Cantidad_vendida | int(45) | NO | | NULL | | | FK_venta | varchar(20) | NO | MUL | NULL | | | FK_producto | varchar(20) | NO | MUL | NULL | | +------------------+-------------+------+-----+---------+-------+ 4 rows in set (0.024 sec) MariaDB [inventario]> drop table Detalles_Pedido; Query OK, 0 rows affected (0.125 sec) MariaDB [inventario]> create table Detalles_Pedido -> (id_detallePedi varchar(20) not null primary key, -> Nombre varchar(45) not null, -> camtidad_pedido int(45) not null, -> Precio_compra int(45) not null, -> FK_pedidoProve varchar(20) not null, -> FK_produto varchar(20) not null, -> foreign key(FK_pedidoProve) references Pedidos_Proveedores(id_pedidoProve) on delete cascade on update cascade, -> foreign key(FK_produto) references producto(id_producto) on delete cascade on update cascade); Query OK, 0 rows affected (0.036 sec) MariaDB [inventario]> describe Detalles_Pedido; +-----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+-------+ | id_detallePedi | varchar(20) | NO | PRI | NULL | | | Nombre | varchar(45) | NO | | NULL | | | camtidad_pedido | int(45) | NO | | NULL | | | Precio_compra | int(45) | NO | | NULL | | | FK_pedidoProve | varchar(20) | NO | MUL | NULL | | | FK_produto | varchar(20) | NO | MUL | NULL | | +-----------------+-------------+------+-----+---------+-------+ 6 rows in set (0.018 sec) MariaDB [inventario]> insert into producto values('P001', 'Refrigerador', 1500000, 0, 50),('P002', 'Lavadora', 1200000, 0, 30),('P003', 'Microondas', 300000, 0, 100),('P004', 'Horno', 700000, 0, 60),('P005', 'Licuadora', 150000, 0, 200),('P006', 'Aspiradora', 500000, 0, 80),('P007', 'Televisor', 2000000, 0, 40),('P008', 'Ventilador', 80000, 0, 150),('P009', 'Cafetera', 120000, 0, 120),('P010', 'Plancha', 90000, 0, 70); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from acudiente; ERROR 1146 (42S02): Table 'inventario.acudiente' doesn't exist MariaDB [inventario]> select * from producto; +-------------+--------------+--------------+--------------+------------+ | id_producto | Nombre | Precio_costo | Precio_venta | Disponible | +-------------+--------------+--------------+--------------+------------+ | P001 | Refrigerador | 1500000 | 0 | 50 | | P002 | Lavadora | 1200000 | 0 | 30 | | P003 | Microondas | 300000 | 0 | 100 | | P004 | Horno | 700000 | 0 | 60 | | P005 | Licuadora | 150000 | 0 | 200 | | P006 | Aspiradora | 500000 | 0 | 80 | | P007 | Televisor | 2000000 | 0 | 40 | | P008 | Ventilador | 80000 | 0 | 150 | | P009 | Cafetera | 120000 | 0 | 120 | | P010 | Plancha | 90000 | 0 | 70 | +-------------+--------------+--------------+--------------+------------+ 10 rows in set (0.000 sec) MariaDB [inventario]> insert into proveedores values('PR001', 'ElectroHouse', '3001234567', 'Medellin'),('PR002', 'MegaElectro', '3012345678', 'Bogota'),('PR003', 'HogarPlus', '3023456789', 'Cali'),('PR004', 'TecnoElectro', '3034567890', 'Barranquilla'),('PR005', 'ElectroCenter', '3045678901', 'Cartagena'),('PR006', 'HomeElectronics', '3056789012', 'Pereira'),('PR007', 'TotalElectro', '3067890123', 'Bucaramanga'),('PR008', 'ElectroService', '3078901234', 'Santa Marta'),('PR009', 'ElectroDistribuidora', '3089012345', 'Manizales'),('PR010', 'ElectroTienda', '3090123456', 'Ibagu‚'); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from proveedores; +--------------+----------------------+------------+--------------+ | id_proveedor | Nombre | Telefono | Ciudad | +--------------+----------------------+------------+--------------+ | PR001 | ElectroHouse | 3001234567 | Medellin | | PR002 | MegaElectro | 3012345678 | Bogota | | PR003 | HogarPlus | 3023456789 | Cali | | PR004 | TecnoElectro | 3034567890 | Barranquilla | | PR005 | ElectroCenter | 3045678901 | Cartagena | | PR006 | HomeElectronics | 3056789012 | Pereira | | PR007 | TotalElectro | 3067890123 | Bucaramanga | | PR008 | ElectroService | 3078901234 | Santa Marta | | PR009 | ElectroDistribuidora | 3089012345 | Manizales | | PR010 | ElectroTienda | 3090123456 | Ibagu‚ | +--------------+----------------------+------------+--------------+ 10 rows in set (0.000 sec) MariaDB [inventario]> insert into Cliente values('C001', 'Juan Perez', '3111234567', 'Medellin'),('C002', 'Ana Martinez', '3122345678', 'Bogota'),('C003', 'Carlos Gomez', '3133456789', 'Cali'),('C004', 'Laura Rodriguez', '3144567890', 'Barranquilla'),('C005', 'Luis Fernandez', '3155678901', 'Medellin'),('C006', 'Marta Suarez', '3166789012', 'Medellin'),('C007', 'David Ramirez', '3177890123', 'Bogota'),('C008', 'Gloria Ortiz', '3188901234', 'Santa Marta'),('C009', 'Rosa Morales', '3199012345', 'Cali'),('C010', 'Pedro Rios', '3100123456', 'Medellin'); Query OK, 10 rows affected (0.003 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from Cliente; +------------+-----------------+------------+--------------+ | id_cliente | Nombre | Telefono | Ciudad | +------------+-----------------+------------+--------------+ | C001 | Juan Perez | 3111234567 | Medellin | | C002 | Ana Martinez | 3122345678 | Bogota | | C003 | Carlos Gomez | 3133456789 | Cali | | C004 | Laura Rodriguez | 3144567890 | Barranquilla | | C005 | Luis Fernandez | 3155678901 | Medellin | | C006 | Marta Suarez | 3166789012 | Medellin | | C007 | David Ramirez | 3177890123 | Bogota | | C008 | Gloria Ortiz | 3188901234 | Santa Marta | | C009 | Rosa Morales | 3199012345 | Cali | | C010 | Pedro Rios | 3100123456 | Medellin | +------------+-----------------+------------+--------------+ 10 rows in set (0.000 sec) MariaDB [inventario]> insert into Pedidos_Proveedores values('PP001', '2024-10-01', 'PR001'),('PP002', '2024-10-02', 'PR002'),('PP003', '2024-10-03', 'PR003'),('PP004', '2024-10-04', 'PR004'),('PP005', '2024-10-05', 'PR005'); Query OK, 5 rows affected (0.003 sec) Records: 5 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from Pedidos_Proveedores; +----------------+------------+--------------+ | id_pedidoProve | Fecha | FK_proveedor | +----------------+------------+--------------+ | PP001 | 2024-10-01 | PR001 | | PP002 | 2024-10-02 | PR002 | | PP003 | 2024-10-03 | PR003 | | PP004 | 2024-10-04 | PR004 | | PP005 | 2024-10-05 | PR005 | +----------------+------------+--------------+ 5 rows in set (0.000 sec) MariaDB [inventario]> insert into Detalles_Pedido values('DP001', 'Refrigerador Grande', 10, 1400000, 'PP001', 'P001'),('DP002', 'Lavadora Compacta', 15, 1150000, 'PP002', 'P002'),('DP003', 'Microondas Digital', 20, 290000, 'PP003', 'P003'),('DP004', 'Horno Electrico', 25, 680000, 'PP004', 'P004'),('DP005', 'Licuadora Potente', 30, 145000, 'PP005', 'P005'); Query OK, 5 rows affected (0.003 sec) Records: 5 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from Detalles_Pedido; +----------------+---------------------+-----------------+---------------+----------------+------------+ | id_detallePedi | Nombre | camtidad_pedido | Precio_compra | FK_pedidoProve | FK_produto | +----------------+---------------------+-----------------+---------------+----------------+------------+ | DP001 | Refrigerador Grande | 10 | 1400000 | PP001 | P001 | | DP002 | Lavadora Compacta | 15 | 1150000 | PP002 | P002 | | DP003 | Microondas Digital | 20 | 290000 | PP003 | P003 | | DP004 | Horno Electrico | 25 | 680000 | PP004 | P004 | | DP005 | Licuadora Potente | 30 | 145000 | PP005 | P005 | +----------------+---------------------+-----------------+---------------+----------------+------------+ 5 rows in set (0.000 sec) MariaDB [inventario]> insert into venta values ('V001', '2024-10-15', 'C001'),('V002', '2024-10-16', 'C002'),('V003', '2024-10-17', 'C003'),('V004', '2024-10-18', 'C004'),('V005', '2024-10-19', 'C005'),('V006', '2024-10-20', 'C006'),('V007', '2024-10-21', 'C007'),('V008', '2024-10-22', 'C008'),('V009', '2024-10-23', 'C009'),('V010', '2024-10-24', 'C010'); Query OK, 10 rows affected (0.004 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from venta; +----------+------------+------------+ | id_venta | Fecha | FK_cliente | +----------+------------+------------+ | V001 | 2024-10-15 | C001 | | V002 | 2024-10-16 | C002 | | V003 | 2024-10-17 | C003 | | V004 | 2024-10-18 | C004 | | V005 | 2024-10-19 | C005 | | V006 | 2024-10-20 | C006 | | V007 | 2024-10-21 | C007 | | V008 | 2024-10-22 | C008 | | V009 | 2024-10-23 | C009 | | V010 | 2024-10-24 | C010 | +----------+------------+------------+ 10 rows in set (0.001 sec) MariaDB [inventario]> insert into Detalles_Venta values('DV001', 2, 'V001', 'P001'),('DV002', 1, 'V002', 'P002'),('DV003', 3, 'V003', 'P003'),('DV004', 2, 'V004', 'P004'),('DV005', 1, 'V005', 'P005'),('DV006', 2, 'V006', 'P006'),('DV007', 1, 'V007', 'P007'),('DV008', 4, 'V008', 'P008'),('DV009', 2, 'V009', 'P009'),('DV010', 3, 'V010', 'P010'); Query OK, 10 rows affected (0.007 sec) Records: 10 Duplicates: 0 Warnings: 0 MariaDB [inventario]> select * from Detalles_Venta; +----------------+------------------+----------+-------------+ | id_detalleVent | Cantidad_vendida | FK_venta | FK_producto | +----------------+------------------+----------+-------------+ | DV001 | 2 | V001 | P001 | | DV002 | 1 | V002 | P002 | | DV003 | 3 | V003 | P003 | | DV004 | 2 | V004 | P004 | | DV005 | 1 | V005 | P005 | | DV006 | 2 | V006 | P006 | | DV007 | 1 | V007 | P007 | | DV008 | 4 | V008 | P008 | | DV009 | 2 | V009 | P009 | | DV010 | 3 | V010 | P010 | +----------------+------------------+----------+-------------+ 10 rows in set (0.000 sec) MariaDB [inventario]> exit