MariaDB [(none)]> use Libreria Database changed MariaDB [Libreria]> create table Materia -> (Codigmat varchar(10) not null primary key, -> Nombre varchar(50) not null); Query OK, 0 rows affected (0.024 sec) MariaDB [Libreria]> describe Materia; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | Codigmat | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(50) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.015 sec) MariaDB [Libreria]> create table Autor -> (codautor varchar(10) not null primary key, -> Nombre varchar(50) not null); Query OK, 0 rows affected (0.031 sec) MariaDB [Libreria]> describe Autor; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | codautor | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(50) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.015 sec) MariaDB [Libreria]> create table Editorial -> (codedit varchar(10) not null primary key, -> Nombre vachar(50) 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 '(50) not null)' at line 3 MariaDB [Libreria]> create table Editorial -> (codedit varchar(10) not null primary key, -> Nombre varchar(50) not null); Query OK, 0 rows affected (0.031 sec) MariaDB [Libreria]> describe Editorial; +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | codedit | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(50) | NO | | NULL | | +---------+-------------+------+-----+---------+-------+ 2 rows in set (0.016 sec) MariaDB [Libreria]> create table Libro -> (idlibro varchar(10) not null primary key, -> Titulo varchar(50) not null, -> NroPaginas int(3) not null, -> Precio int(8) not null, -> codigmat varchar(10) not null, -> -> foreing key(codigmat) references materia(codigmat) 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 'key(codigmat) references materia(codigmat) on delete cascade on update cascade)' at line 8 MariaDB [Libreria]> create table Libro -> (idlibro varchar(10) not null primary key, -> Titulo varchar(50) not null, -> NroPaginas int(3) not null, -> Precio int(8) not null, -> codigmat1 varchar(10) not null, -> foreigs -> ; 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 7 MariaDB [Libreria]> create table Libro -> (idlibro varchar(10) not null primary key, -> Titulo varchar(50) not null, -> NroPaginas int(3) not null, -> Precio int(8) not null, -> codigmat varchar(10) not null, -> foreign key(codigmat) references materia(codigmat) on delete cascade on update cascade); Query OK, 0 rows affected (0.031 sec) MariaDB [Libreria]> describe Libro; +------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+-------+ | idlibro | varchar(10) | NO | PRI | NULL | | | Titulo | varchar(50) | NO | | NULL | | | NroPaginas | int(3) | NO | | NULL | | | Precio | int(8) | NO | | NULL | | | codigmat | varchar(10) | NO | MUL | NULL | | +------------+-------------+------+-----+---------+-------+ 5 rows in set (0.015 sec) MariaDB [Libreria]> create table LIAUTEDI -> (idlibro varchar(10) not null, -> codautor varchar(10) not null, -> codedit varchar(10) not null, -> foreign key(idlibro) references libro(idlibro) on delete cascede on update cascade, -> foreign key(codautor) references autor(codautor) on delete cascade on update cascade, -> foreign key(codedit) references editorial(codedit) 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 'cascede on update cascade, foreign key(codautor) references autor(codautor) o...' at line 5 MariaDB [Libreria]> create table LIAUTEDI -> (idlibro varchar(10) not null, -> codautor varchar(10) not null, -> codedit varchar(10) not null, -> foreign key(idlibro) references libro(idlibro) on delete cascade on update cascade, -> foreign key(codautor) references autor(codautor) on delete cascade on update cascade, -> foreign key(codedit) references editorial(codedit) on delete cascade on update cascade); Query OK, 0 rows affected (0.034 sec) MariaDB [Libreria]> describe Liautedi -> -> ; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | idlibro | varchar(10) | NO | MUL | NULL | | | codautor | varchar(10) | NO | MUL | NULL | | | codedit | varchar(10) | NO | MUL | NULL | | +----------+-------------+------+-----+---------+-------+ 3 rows in set (0.015 sec) MariaDB [Libreria]> alter table libro change titulo descripcion; 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 1 MariaDB [Libreria]> alter table libro change titulo descripcion varchar(50) not null; Query OK, 0 rows affected (0.030 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [Libreria]> describe libro; +-------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | idlibro | varchar(10) | NO | PRI | NULL | | | descripcion | varchar(50) | NO | | NULL | | | NroPaginas | int(3) | NO | | NULL | | | Precio | int(8) | NO | | NULL | | | codigmat | varchar(10) | NO | MUL | NULL | | +-------------+-------------+------+-----+---------+-------+ 5 rows in set (0.016 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES (M01,Calculo); ERROR 1054 (42S22): Unknown column 'M01' in 'field list' MariaDB [Libreria]> INSERT INTO MATERIA(codigmat,nombre) VALUES (M01,Calculo); ERROR 1054 (42S22): Unknown column 'M01' in 'field list' MariaDB [Libreria]> INSERT INTO MATERIA(codigmat,nombre) VALUES ('M01','Calculo'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M02','Matematicas'); Query OK, 1 row affected (0.003 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M03','Estructura de datos'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M08','Diagramacion'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M06','Contabilidad'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M07','Redes'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M05','Sistemas de inf.'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M09','Base de datos'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> describe materia -> ; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | Codigmat | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(50) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.016 sec) MariaDB [Libreria]> show table libro; 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 'libro' at line 1 MariaDB [Libreria]> show tables; +--------------------+ | Tables_in_libreria | +--------------------+ | autor | | editorial | | liautedi | | libro | | materia | +--------------------+ 5 rows in set (0.001 sec) MariaDB [Libreria]> select * from libro -> ; Empty set (0.001 sec) MariaDB [Libreria]> select * from libro; Empty set (0.001 sec) MariaDB [Libreria]> select * from materia; +----------+---------------------+ | Codigmat | Nombre | +----------+---------------------+ | M01 | Calculo | | M02 | Matematicas | | M03 | Estructura de datos | | M05 | Sistemas de inf. | | M06 | Contabilidad | | M07 | Redes | | M08 | Diagramacion | | M09 | Base de datos | +----------+---------------------+ 8 rows in set (0.000 sec) MariaDB [Libreria]> INSERT INTO autor VALUES ('A01','Luis Joyanes'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO autor VALUES ('A02','Jorge vasquez Posada'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> INSERT INTO autor VALUES ('A03','Jhon Soars'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO autor VALUES ('A04','Riaz Khadem'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> INSERT INTO autor VALUES ('A05','Rober Lorber'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO autor VALUES ('A06','Mario Dream'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> select * from autor; +----------+----------------------+ | codautor | Nombre | +----------+----------------------+ | A01 | Luis Joyanes | | A02 | Jorge vasquez Posada | | A03 | Jhon Soars | | A04 | Riaz Khadem | | A05 | Rober Lorber | | A06 | Mario Dream | +----------+----------------------+ 6 rows in set (0.000 sec) MariaDB [Libreria]> INSERT INTO editorial VALUES ('E01','Oveja Negra'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO editorial VALUES ('E02','Norma'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> INSERT INTO editorial VALUES ('E03','Mc Graw Hill'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> select * from editorial; +---------+--------------+ | codedit | Nombre | +---------+--------------+ | E01 | Oveja Negra | | E02 | Norma | | E03 | Mc Graw Hill | +---------+--------------+ 3 rows in set (0.000 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L01','Calculo II',120,55000); ERROR 1136 (21S01): Column count doesn't match value count at row 1 MariaDB [Libreria]> select * from libro; Empty set (0.000 sec) MariaDB [Libreria]> select * from LIAUTEDI; Empty set (0.000 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L01','Calculo II',120,55000,'M01'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> select * from libro; +---------+-------------+------------+--------+----------+ | idlibro | descripcion | NroPaginas | Precio | codigmat | +---------+-------------+------------+--------+----------+ | L01 | Calculo II | 120 | 55000 | M01 | +---------+-------------+------------+--------+----------+ 1 row in set (0.000 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L02','BD II',150,65000,'M09'); Query OK, 1 row affected (0.005 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L03','Estructura de datos',180,85000,'M03'); Query OK, 1 row affected (0.003 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L08','Diagramacion',85,45000,'M08'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L05','Admon de una pagina',70,7500,'M05'); Query OK, 1 row affected (0.003 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L06','Contabilidad I',170,27500,'M06'); Query OK, 1 row affected (0.004 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L07','Redes',370,32500,'M07'); Query OK, 1 row affected (0.003 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L04','Ingles',280,105000,'M04'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`libreria`.`libro`, CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigmat`) REFERENCES `materia` (`Codigmat`) ON DELETE CASCADE ON UPDATE CASCADE) MariaDB [Libreria]> INSERT INTO MATERIA VALUES ('M04','Ingl'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO Libro VALUES ('L04','Ingles',280,105000,'M04'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> select * from libro; +---------+---------------------+------------+--------+----------+ | idlibro | descripcion | NroPaginas | Precio | codigmat | +---------+---------------------+------------+--------+----------+ | L01 | Calculo II | 120 | 55000 | M01 | | L02 | BD II | 150 | 65000 | M09 | | L03 | Estructura de datos | 180 | 85000 | M03 | | L04 | Ingles | 280 | 105000 | M04 | | L05 | Admon de una pagina | 70 | 7500 | M05 | | L06 | Contabilidad I | 170 | 27500 | M06 | | L07 | Redes | 370 | 32500 | M07 | | L08 | Diagramacion | 85 | 45000 | M08 | +---------+---------------------+------------+--------+----------+ 8 rows in set (0.000 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L02','A01','E01'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L02','A05','E03'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L06','A02','E02'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L07','A05','E03'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L04','A04','E01'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L04','A04','E02'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> INSERT INTO LIAUTEDI VALUES ('L04','A04','E03'); Query OK, 1 row affected (0.002 sec) MariaDB [Libreria]> select * from LIAUTEDI; +---------+----------+---------+ | idlibro | codautor | codedit | +---------+----------+---------+ | L02 | A01 | E01 | | L02 | A05 | E03 | | L06 | A02 | E02 | | L07 | A05 | E03 | | L04 | A04 | E01 | | L04 | A04 | E02 | | L04 | A04 | E03 | +---------+----------+---------+ 7 rows in set (0.001 sec) MariaDB [Libreria]> select descripcion from libro; +---------------------+ | descripcion | +---------------------+ | Calculo II | | BD II | | Estructura de datos | | Ingles | | Admon de una pagina | | Contabilidad I | | Redes | | Diagramacion | +---------------------+ 8 rows in set (0.000 sec) MariaDB [Libreria]> select descripcion,precios from libro; ERROR 1054 (42S22): Unknown column 'precios' in 'field list' MariaDB [Libreria]> select descripcion,precio from libro; +---------------------+--------+ | descripcion | precio | +---------------------+--------+ | Calculo II | 55000 | | BD II | 65000 | | Estructura de datos | 85000 | | Ingles | 105000 | | Admon de una pagina | 7500 | | Contabilidad I | 27500 | | Redes | 32500 | | Diagramacion | 45000 | +---------------------+--------+ 8 rows in set (0.000 sec) MariaDB [Libreria]> ALTER TABLE Materia RENAME TO Asignatura -> ; Query OK, 0 rows affected (0.015 sec) MariaDB [Libreria]> describe asignatura -> ; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | Codigmat | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(50) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.015 sec) MariaDB [Libreria]> describe asignatura; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | Codigmat | varchar(10) | NO | PRI | NULL | | | Nombre | varchar(50) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.017 sec)