MariaDB [(none)]> create database Inventario; Query OK, 1 row affected (0.001 sec) 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.056 sec) MariaDB [(none)]> use inventario; Database changed MariaDB [inventario]> create table Producto -> (id_producto varchar(20) not null primary key, -> Nombre varchar(45) not null, -> Precio_costo int(45) not null, -> Precio_venta int(45) not null, -> Disponible int(45) not null); Query OK, 0 rows affected (0.008 sec) 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.025 sec) MariaDB [inventario]> create table Proveedores -> Nombre varchar(45) not null, -> Telefono varchar(45) not null,; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'varchar(45) not null, Telefono varchar(45) not null,' at line 2 MariaDB [inventario]> create table Proveedores -> (id_proveedor varchar(20) not null primary key, -> Nombre varchar(45) not null, -> Telefono varchar(45) not null, -> Ciudad varchar(45) not null); Query OK, 0 rows affected (0.010 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.018 sec) MariaDB [inventario]> create table Cliente -> (id_cliente varchar(20) not null primary key, -> Nombre varchar(45) not null, -> Telefono varchar(45) not null, -> Ciudad varchar(45) not null); Query OK, 0 rows affected (0.009 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.019 sec) MariaDB [inventario]> create table Pedidos_Proveedores -> (id_pedidoProve varchar(20) not null primary key, -> Fecha varchar(45) not null, -> FK_proveedor int(20) not null, -> foreign key(FK_proveedor) references acudiente(id_proveedor) on delete cascade on update cascade); ERROR 1005 (HY000): Can't create table `inventario`.`pedidos_proveedores` (errno: 150 "Foreign key constraint is incorrectly formed") MariaDB [inventario]> CREATE TABLE Pedidos_Proveedores ( id_pedidoProve VARCHAR(20) NOT NULL PRIMARY KEY, Fecha VARCHAR(45) NOT NULL, FK_proveedor INT NOT NULL, FOREIGN KEY (FK_proveedor) REFERENCES acudiente(id_proveedor) ON DELETE CASCADE ON UPDATE CASCADE); ERROR 1005 (HY000): Can't create table `inventario`.`pedidos_proveedores` (errno: 150 "Foreign key constraint is incorrectly formed") MariaDB [inventario]> create table Pedidos_Proveedores -> (id_pedidoProve varchar(20) not null primary key, -> Fecha varchar(45) not null, -> FK_proveedor INT NOT NULL, -> FOREIGN KEY (FK_proveedor) REFERENCES acudiente(id_proveedor) ON DELETE CASCADE ON UPDATE CASCADE); ERROR 1005 (HY000): Can't create table `inventario`.`pedidos_proveedores` (errno: 150 "Foreign key constraint is incorrectly formed") MariaDB [inventario]> create table Pedidos_Proveedores -> (id_pedidoProve varchar(20) not null primary key, -> Fecha varchar(45) not null); Query OK, 0 rows affected (0.011 sec) MariaDB [inventario]> create table Pedidos_Proveedores -> FK_proveedor int(20) not null, -> foreign key(FK_proveedor) references acudiente(id_proveedor) on delete cascade on update cascade; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'int(20) not null, foreign key(FK_proveedor) references acudiente(id_proveedor...' at line 2 MariaDB [inventario]> create table Pedidos_Proveedores -> (FK_proveedor int(20) not null, -> foreign key(FK_proveedor) references acudiente(id_proveedor) on delete cascade on update cascade); ERROR 1050 (42S01): Table 'pedidos_proveedores' already exists MariaDB [inventario]> drop table Pedidos_Proveedores; Query OK, 0 rows affected (0.083 sec) MariaDB [inventario]> create table Pedidos_Proveedores -> (id_pedidoProve varchar(20) not null primary key, -> FK_proveedor int(20) not null, -> foreign key(FK_proveedor) references proveedores(id_proveedor) on delete cascade on update cascade); ERROR 1005 (HY000): Can't create table `inventario`.`pedidos_proveedores` (errno: 150 "Foreign key constraint is incorrectly formed") MariaDB [inventario]> create table Pedidos_Proveedores -> (id_pedidoProve varchar(20) not null primary key, -> Fecha varchar(45) not null, -> FK_proveedor varchar(20) not null, -> foreign key(FK_proveedor) references proveedores(id_proveedor) on delete cascade on update cascade); Query OK, 0 rows affected (0.035 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.027 sec) MariaDB [inventario]> create table Detalles_Pedido -> (id_detallePedi varchar(20) not null primary key, -> camtidad_pedido varchar(45) not null, -> Precio_compra varchar(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 | | | camtidad_pedido | varchar(45) | NO | | NULL | | | Precio_compra | varchar(45) | NO | | NULL | | | FK_pedidoProve | varchar(20) | NO | MUL | NULL | | | FK_produto | varchar(20) | NO | MUL | NULL | | +-----------------+-------------+------+-----+---------+-------+ 5 rows in set (0.017 sec) MariaDB [inventario]> drop table Detalles_Pedido; Query OK, 0 rows affected (0.007 sec) MariaDB [inventario]> create table Detalles_Pedido -> (id_pedidoProve varchar(20) not null primary key, -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2 MariaDB [inventario]> create table Detalles_Pedido -> (id_detallePedi varchar(20) not null primary key, -> 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.040 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.018 sec) MariaDB [inventario]> create table Venta -> (id_venta varchar(20) not null primary key, -> Fecha varchar(45) not null, -> FK_cliente varchar(20) not null, -> foreign key(FK_cliente) references cliente(id_cliente) on delete cascade on update cascade); Query OK, 0 rows affected (0.055 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.019 sec) MariaDB [inventario]> create table Detalles_Venta -> (id_detalleVent varchar(20) not null primary key, -> Cantidad_vendida int(45) not null, -> FK_venta varchar(20) not null, -> FK_producto varchar(20) not null, -> foreign key(FK_venta) references venta(id_venta) on delete cascade on update cascade, -> foreign key(FK_producto) references producto(id_producto) on delete cascade on update cascade); Query OK, 0 rows affected (0.035 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.019 sec) MariaDB [inventario]> exit