Microsoft Windows [Versión 6.1.7601] Copyright (c) 2009 Microsoft Corporation. Reservados todos los derechos. C:\Users\601-03>cd\xampp\mysql\bin C:\xampp\mysql\bin>mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.27 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cdcol | | mysql | | performance_schema | | phpmyadmin | | test | | webauth | +--------------------+ 7 rows in set (0.03 sec) mysql> create database biblioteca; Query OK, 1 row affected (0.00 sec) mysql> use biblioteca; Database changed mysql> create table libro -> (cod_lib char(10) not null primary key, -> nombre char(40) not null) engine=innodb; Query OK, 0 rows affected (0.08 sec) mysql> create table autor -> (cod_aut char(10) not null primary key, -> nombre char(40) not null) engine=innodb; Query OK, 0 rows affected (0.06 sec) mysql> create table editorial -> (cod_edi char(10) not null primary key, -> nombre char(40) not null) engine=innodb; Query OK, 0 rows affected (0.05 sec) mysql> show tables; +----------------------+ | Tables_in_biblioteca | +----------------------+ | autor | | editorial | | libro | +----------------------+ 3 rows in set (0.00 sec) mysql> create table libro_aut -> (cod_lib char(10) not null, -> cod_aut char(10) not null, -> foreign key (cod_lib) references libro (cod_lib) on delete cascade on upd ate cascade, -> foreign key (cod_aut) references autor (cod_aut) on delete cascade on upd ate cascade) engine=innodb; Query OK, 0 rows affected (0.06 sec) mysql> create table libro_edi -> (cod_lib char(10) not null, -> cod_edi char(10) not null, -> foreign key (cod_lib) references libro (cod_lib) on delete cascade on upd ate cascade, -> foreign key (cod_edi) references editorial (cod_edi) on delete cascade on update cascade) engine=innodb; Query OK, 0 rows affected (0.09 sec) mysql> show tables; +----------------------+ | Tables_in_biblioteca | +----------------------+ | autor | | editorial | | libro | | libro_aut | | libro_edi | +----------------------+ 5 rows in set (0.00 sec) mysql> describe autor; +---------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+-------+ | cod_aut | char(10) | NO | PRI | NULL | | | nombre | char(40) | NO | | NULL | | +---------+----------+------+-----+---------+-------+ 2 rows in set (0.03 sec) mysql> insert into autor (cod_aut,nombre) values (001,"rafael pombo"); Query OK, 1 row affected (0.01 sec) mysql> insert into autor (cod_aut,nombre) values (002,"gabriel garcia marquez"); Query OK, 1 row affected (0.01 sec) mysql> insert into autor (cod_aut,nombre) values (003,"ernesto martinez"); Query OK, 1 row affected (0.02 sec) mysql> select*from autor; +---------+------------------------+ | cod_aut | nombre | +---------+------------------------+ | 1 | rafael pombo | | 2 | gabriel garcia marquez | | 3 | ernesto martinez | +---------+------------------------+ 3 rows in set (0.00 sec) mysql> describe libro; +---------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+-------+ | cod_lib | char(10) | NO | PRI | NULL | | | nombre | char(40) | NO | | NULL | | +---------+----------+------+-----+---------+-------+ 2 rows in set (0.01 sec) mysql> insert into libro (cod_lib,nombre) values (001,"la voragine"); Query OK, 1 row affected (0.00 sec) mysql> insert into libro (cod_lib,nombre) values (002,"la esperanza perdida"); Query OK, 1 row affected (0.01 sec) mysql> insert into libro (cod_lib,nombre) values (003,"el amor en los tiempos de l colera"); Query OK, 1 row affected (0.00 sec) mysql> select*from libro; +---------+-----------------------------------+ | cod_lib | nombre | +---------+-----------------------------------+ | 1 | la voragine | | 2 | la esperanza perdida | | 3 | el amor en los tiempos del colera | +---------+-----------------------------------+ 3 rows in set (0.00 sec) mysql> describe editorial; +---------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+-------+ | cod_edi | char(10) | NO | PRI | NULL | | | nombre | char(40) | NO | | NULL | | +---------+----------+------+-----+---------+-------+ 2 rows in set (0.03 sec) mysql> insert into editorial (cod_edi,nombre) values (001,"todo libros"); Query OK, 1 row affected (0.01 sec) mysql> insert into editorial (cod_edi,nombre) values (002,"mc graw hill"); Query OK, 1 row affected (0.02 sec) mysql> insert into editorial (cod_edi,nombre) values (003,"edition mall"); Query OK, 1 row affected (0.00 sec) mysql> select*from editorial; +---------+--------------+ | cod_edi | nombre | +---------+--------------+ | 1 | todo libros | | 2 | mc graw hill | | 3 | edition mall | +---------+--------------+ 3 rows in set (0.00 sec) mysql> describe libro_aut; +---------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+-------+ | cod_lib | char(10) | NO | MUL | NULL | | | cod_aut | char(10) | NO | MUL | NULL | | +---------+----------+------+-----+---------+-------+ 2 rows in set (0.02 sec) mysql> insert into libro_aut (cod_lib,cod_aut) values (001,002); Query OK, 1 row affected (0.02 sec) mysql> insert into libro_aut (cod_lib,cod_aut) values (002,003); Query OK, 1 row affected (0.02 sec) mysql> insert into libro_aut (cod_lib,cod_aut) values (002,001); Query OK, 1 row affected (0.02 sec) mysql> describe libro_edi; +---------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+-------+ | cod_lib | char(10) | NO | MUL | NULL | | | cod_edi | char(10) | NO | MUL | NULL | | +---------+----------+------+-----+---------+-------+ 2 rows in set (0.01 sec) mysql> insert into libro_edi (cod_lib,cod_edi) values (001,001); Query OK, 1 row affected (0.00 sec) mysql> insert into libro_edi (cod_lib,cod_edi) values (002,003); Query OK, 1 row affected (0.00 sec) mysql> insert into libro_edi (cod_lib,cod_edi) values (002,001); Query OK, 1 row affected (0.02 sec) mysql> select*from libro_edi; +---------+---------+ | cod_lib | cod_edi | +---------+---------+ | 1 | 1 | | 2 | 3 | | 2 | 1 | +---------+---------+ 3 rows in set (0.00 sec) mysql>mysqldump -B -uroot -p biblioteca>d:\biblioteca.sql