PRACTICA 3
mysql> use biblioteca;
Database changed
mysql> insert into autor values(120060,'carlos
cuautemoc');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into autor values(120070,'carlos fuentes');
Query OK, 1 row affected (0.00 sec)
mysql> insert into autor values(120080,'gabriel garcia');
Query OK, 1 row affected (0.00 sec)
mysql> insert into libro values(12345,'retrato de dorian
grey',7592757367,'bob',
113,2007/10/07);
Query OK, 1 row affected, 2 warnings (0.05 sec)
mysql> insert into libro values(12346,'en pie de guerra',9482473451,'tomo',187,1
999/07/18);
Query OK, 1 row affected, 2 warnings (0.00 sec)
mysql> insert into libro values(12347,'como es mi
cuerpo',5327218502,'mxn',225,1
997/09/20);
Query OK, 1 row affected, 2 warnings (0.00 sec)
mysql> insert into usuario values(044556,'angel',59460963,'independencia',12,'be
nito juarez','mexico',54942);
Query OK, 1 row affected (0.00 sec)
mysql> insert into usuario
values(044557,'amairani',48618754,'carrillo puerto',1
0,'benito juarez','mexico',54942);
Query OK, 1 row affected (0.00 sec)
mysql> insert into usuario
values(044558,'karla',30709978,'carrillo puerto',24,'
benito juarez','mexico',54942);
Query OK, 1 row affected (0.00 sec)
mysql> insert into ejemplar values(005,'pasillo1
linea4');
Query OK, 1 row affected (0.00 sec)
mysql> insert into ejemplar values(006,'pasillo2
linea8');
Query OK, 1 row affected (0.00 sec)
mysql> insert into ejemplar values(007,'pasillo2
linea2');
Query OK, 1 row affected (0.00 sec)
>
mysql> alter table escribe add foreign key(codigo_autor)references autor(codigo);
Query OK, 0 rows affected (0.12 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table escribe add foreign key(codigo_autor)references libro(codigo);
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe escribe;
+--------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------+------+-----+---------+-------+
| codigo_autor | int(11) | YES | MUL | NULL | |
| codigo_libro | int(11) | YES | | NULL | |
+--------------+---------+------+-----+---------+-------+
2 rows in set (0.10 sec)
mysql> alter table saca add foreign key(codigo_ejemplar)references usuario(codig
o);
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table saca add foreign key(codigo_usuario)references usuario(codigo);
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe saca;
+------------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------+------+-----+---------+-------+
| codigo_usuario | int(11) | YES | MUL | NULL | |
| codigo_ejemplar | int(11) | YES | MUL | NULL | |
| fecha_devolucion | date | YES | | NULL | |
| fecha_prestamo | date | YES | | NULL | |
+------------------+---------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql
No hay comentarios.:
Publicar un comentario