Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE DATABASE libreria;
- USE libreria;
- CREATE TABLE Autor (
- idAutor SMALLINT NOT NULL AUTO_INCREMENT,
- nombreAutor VARCHAR(50) NOT NULL,
- apellidoAutor VARCHAR(50) NOT NULL,
- correoAutor VARCHAR(50),
- NacimientoAutor DATE NOT NULL,
- PRIMARY KEY (idAutor)
- );
- INSERT INTO Autor (idAutor, nombreAutor, apellidoAutor, correoAutor, NacimientoAutor) VALUES
- (DEFAULT, 'Octavio', 'Paz', NULL, '1914-03-31'),
- (DEFAULT, 'César', 'Vallejo', NULL, '1892-03-16'),
- (DEFAULT, 'Julio', 'Cortázar', NULL, '1914-08-26'),
- (DEFAULT, 'José', 'Donoso', NULL, '1924-10-05');
- CREATE TABLE Editorial (
- idEditorial SMALLINT NOT NULL AUTO_INCREMENT,
- nombreEditorial VARCHAR(50) NOT NULL,
- telefonoEditorial VARCHAR(25) NOT NULL,
- correoEditorial VARCHAR(50) NOT NULL,
- webEditorial VARCHAR(100) NOT NULL,
- PRIMARY KEY (idEditorial)
- );
- INSERT INTO Editorial (idEditorial, nombreEditorial, telefonoEditorial, correoEditorial, webEditorial) VALUES
- (DEFAULT, 'Ediciones del Sur Argentina', '+54 1112345678', '[email protected]', 'www.edicionesdelsur.com.ar'),
- (DEFAULT, 'Editorial Nacional Brasileña', '+55 21987654321', '[email protected]', 'www.editorialnacional.com.br'),
- (DEFAULT, 'Publicaciones Chilena S.A.', '+56 2 87654321', '[email protected]', 'www.publicacioneschilena.cl'),
- (DEFAULT, 'Ediciones Centroamericana', '+502 2222-3333', '[email protected]', 'www.edicionescentroamericana.gt'),
- (DEFAULT, 'Editorial Ecuatoriana Andina', '+593 2555-6666', '[email protected]', 'www.editorialecuatoriana.com.ec'),
- (DEFAULT, 'Libros Caribeños Colombia', '+57 1 4445555', '[email protected]', 'www.libroscaribenos.com.co'),
- (DEFAULT, 'Ediciones Caribe México', '+52 55 7777-8888', '[email protected]', 'www.edicionescaribe.mx'),
- (DEFAULT, 'Editorial Sudamericana Perú', '+51 699888777', '[email protected]', 'www.editorialsudamericana.pe'),
- (DEFAULT, 'Publicaciones Latinoamérica', '+598 23333-4444', '[email protected]', 'www.publicacioneslatinoamerica.com.uy'),
- (DEFAULT, 'Ediciones Panamá Internacional', '+507 6666-7777', '[email protected]', 'www.edicionespanama.com.pa');
- CREATE TABLE LugarImpresion (
- idLugarImpresion SMALLINT NOT NULL AUTO_INCREMENT,
- direccionLugar VARCHAR(100) NOT NULL,
- capacidadProduccion INT,
- estadoOperativo BOOLEAN,
- PRIMARY KEY (idLugarImpresion)
- );
- INSERT INTO LugarImpresion (idLugarImpresion, direccionLugar, capacidadProduccion, estadoOperativo) VALUES
- (DEFAULT, 'Av. Independencia 123, Buenos Aires, Argentina', 5000, TRUE),
- (DEFAULT, 'Rua das Letras 456, Rio de Janeiro, Brasil', 7000, TRUE),
- (DEFAULT, 'Calle de las Imprentas, Santiago, Chile', 6000, TRUE),
- (DEFAULT, 'Avenida de las Ediciones, Guatemala City, Guatemala', 4500, TRUE),
- (DEFAULT, 'Avenida de las Publicaciones , Quito, Ecuador', 5500, TRUE),
- (DEFAULT, 'Carrera de los Libros 567, Bogotá, Colombia', 4800, TRUE),
- (DEFAULT, 'Calle de los Libros 890, Ciudad de México, México', 7200, TRUE),
- (DEFAULT, 'Avenida de las Editoriales, Lima, Perú', 5300, TRUE),
- (DEFAULT, 'Calle de las Publicaciones ABC, Montevideo, Uruguay', 5100, TRUE),
- (DEFAULT, 'Avenida de las Impresiones, Panamá City, Panamá', 4700, TRUE);
- CREATE TABLE Edicion (
- idEdicion SMALLINT NOT NULL AUTO_INCREMENT,
- DetalleEdicion VARCHAR(50) NOT NULL,
- PRIMARY KEY (idEdicion)
- );
- INSERT INTO Edicion (idEdicion, DetalleEdicion) VALUES
- (DEFAULT, 'Primera Edición'),
- (DEFAULT, 'Segunda Edición'),
- (DEFAULT, 'Tercera Edición'),
- (DEFAULT, 'Cuarta Edición'),
- (DEFAULT, 'Quinta Edición'),
- (DEFAULT, 'Sexta Edición'),
- (DEFAULT, 'Edición Limitada'),
- (DEFAULT, 'Edición Especial'),
- (DEFAULT, 'Edición Comercial'),
- (DEFAULT, 'Edición No Comercial');
- CREATE TABLE IdiomaPais (
- idIdiomaPais SMALLINT NOT NULL AUTO_INCREMENT,
- nombreIdioma VARCHAR(50) NOT NULL,
- PRIMARY KEY (idIdiomaPais)
- );
- INSERT INTO IdiomaPais (idIdiomaPais, nombreIdioma) VALUES
- (DEFAULT, 'Español'),
- (DEFAULT, 'Portugués'),
- (DEFAULT, 'Inglés');
- CREATE TABLE Pais (
- idPais SMALLINT NOT NULL AUTO_INCREMENT,
- nombrePais VARCHAR(50) NOT NULL,
- capital VARCHAR(50),
- idIdiomaPais SMALLINT NOT NULL,
- PRIMARY KEY (idPais),
- FOREIGN KEY (idIdiomaPais) REFERENCES IdiomaPais(idIdiomaPais)
- ON DELETE RESTRICT ON UPDATE CASCADE
- );
- INSERT INTO Pais (idPais, nombrePais, capital, idIdiomaPais) VALUES
- (DEFAULT, 'Ecuador', 'Quito', 1),
- (DEFAULT, 'Brasil', 'Brasilia', 2),
- (DEFAULT, 'Argentina', 'Buenos Aires', 1),
- (DEFAULT, 'México', 'Ciudad de México', 1),
- (DEFAULT, 'Colombia', 'Bogotá', 1),
- (DEFAULT, 'Perú', 'Lima', 1),
- (DEFAULT, 'Chile', 'Santiago', 1),
- (DEFAULT, 'Venezuela', 'Caracas', 1),
- (DEFAULT, 'Guatemala', 'Ciudad de Guatemala', 1),
- (DEFAULT, 'Estados Unidos de América', 'Washington D.C.', 3);
- CREATE TABLE TipoLibro (
- idTipoLibro SMALLINT NOT NULL AUTO_INCREMENT,
- tipoLibro VARCHAR(100) NOT NULL,
- detalleTipoLibro TEXT NOT NULL,
- PRIMARY KEY (idTipoLibro)
- );
- INSERT INTO TipoLibro (idTipoLibro, tipoLibro, detalleTipoLibro) VALUES
- (DEFAULT, 'Poesía', 'Emociones en versos y rimas'),
- (DEFAULT, 'Política', 'El juego del poder y la sociedad'),
- (DEFAULT, 'Economía', 'Dinero y comportamiento financiero'),
- (DEFAULT, 'Aventura', 'Emoción y riesgo en historias'),
- (DEFAULT, 'Cocina', 'Recetas y secretos culinarios'),
- (DEFAULT, 'Religión', 'Creencias y espiritualidad'),
- (DEFAULT, 'Viajes', 'Aventuras en distintos lugares'),
- (DEFAULT, 'Tecnología', 'Avances y cambio en la era digital'),
- (DEFAULT, 'Psicología', 'Mente, emociones y comportamiento'),
- (DEFAULT, 'Medicina', 'Salud y bienestar personal');
- CREATE TABLE Libro (
- idLibro SMALLINT NOT NULL AUTO_INCREMENT,
- tituloLibro VARCHAR(100) NOT NULL,
- isbnLibro VARCHAR(20) NOT NULL,
- fechaPublicacion DATE NOT NULL,
- cantidadPaginas SMALLINT NOT NULL,
- precioLibro FLOAT NOT NULL,
- idLugarImpresion SMALLINT NOT NULL,
- FOREIGN KEY (idLugarImpresion) REFERENCES LugarImpresion(idLugarImpresion)
- ON DELETE RESTRICT
- ON UPDATE CASCADE,
- idEditorial SMALLINT NOT NULL,
- FOREIGN KEY (idEditorial) REFERENCES Editorial(idEditorial)
- ON DELETE RESTRICT ON UPDATE CASCADE,
- idTipoLibro SMALLINT NOT NULL,
- FOREIGN KEY (idTipoLibro) REFERENCES TipoLibro(idTipoLibro)
- ON DELETE RESTRICT
- ON UPDATE CASCADE,
- idPais SMALLINT NOT NULL,
- FOREIGN KEY (idPais) REFERENCES Pais(idPais)
- ON DELETE RESTRICT
- ON UPDATE CASCADE,
- idEdicion SMALLINT NOT NULL,
- FOREIGN KEY (idEdicion) REFERENCES Edicion(idEdicion)
- ON DELETE RESTRICT
- ON UPDATE CASCADE,
- PRIMARY KEY (idLibro),
- idAutor SMALLINT NOT NULL,
- FOREIGN KEY (idAutor) REFERENCES Autor(idAutor)
- ON DELETE RESTRICT
- ON UPDATE CASCADE
- );
- INSERT INTO Libro (idLibro, tituloLibro, isbnLibro, precioLibro, cantidadPaginas, fechaPublicacion, idLugarImpresion, idEditorial, idTipoLibro, idPais, idEdicion, idAutor) VALUES
- (DEFAULT, 'El arte de la guerra', '9781973986720', 7.20, 240, '1978-01-01', 1, 4, 3, 2, 7, 5),
- (DEFAULT, 'Moby Dick', '9788491052147', 6.90, 672, '1851-10-18', 3, 9, 5, 1, 3, 9),
- (DEFAULT, 'El guardián entre el centeno', '9780316769488', 7.40, 234, '1951-07-16', 9, 5, 1, 4, 5, 2),
- (DEFAULT, 'Las uvas de la ira', '9780142000663', 7.10, 464, '1939-04-14', 2, 6, 4, 10, 1, 8),
- (DEFAULT, 'Drácula', '9788491051500', 6.85, 418, '1897-05-26', 1, 8, 6, 7, 10, 4),
- (DEFAULT, 'La Odisea', '9780140268867', 7.30, 416, '1611-01-01', 5, 3, 7, 9, 6, 3),
- (DEFAULT, 'El viejo y el mar', '9788491052148', 6.60, 127, '1952-09-01', 10, 7, 4, 8, 9, 6),
- (DEFAULT, 'La divina comedia', '9780141197494', 7.55, 798, '1472-01-01', 8, 1, 5, 3, 8, 7),
- (DEFAULT, 'La isla del tesoro', '9788426132021', 7.25, 312, '1883-01-01', 7, 2, 8, 6, 2, 10),
- (DEFAULT, 'El proceso', '9788491051501', 7.10, 255, '1925-01-01', 4, 10, 3, 5, 4, 1),
- (DEFAULT, 'Robinson Crusoe', '9780141199061', 6.80, 320, '1719-04-25', 1, 5, 9, 2, 3, 8),
- (DEFAULT, 'Hamlet', '9780143794980', 7.60, 342, '1603-01-01', 2, 9, 6, 8, 7, 5),
- (DEFAULT, 'Cien sonetos de amor', '9788426401240', 7.45, 96, '1959-01-01', 3, 6, 1, 4, 5, 9),
- (DEFAULT, 'Alicia en el país de las maravillas', '9788491050062', 6.95, 272, '1865-07-04', 4, 1, 7, 6, 10, 2),
- (DEFAULT, 'La guerra y la paz', '9788499890937', 7.80, 1300, '1869-01-01', 5, 1, 8, 3, 2, 7),
- (DEFAULT, 'La historia interminable', '9788420432292', 7.35, 448, '1979-01-01', 6, 10, 4, 9, 1, 6),
- (DEFAULT, 'La ladrona de libros', '9788499890937', 7.25, 576, '2005-01-01', 7, 3, 9, 10, 6, 5),
- (DEFAULT, 'El nombre del viento', '9788401343610', 7.70, 896, '2007-03-27', 8, 5, 9, 7, 8, 4),
- (DEFAULT, 'El alquimista', '9780062502186', 7.15, 197, '1988-01-01', 9, 1, 3, 1, 5, 10),
- (DEFAULT, 'La casa de los espíritus', '9788408182811', 7.50, 528, '1982-01-01', 10, 5, 9, 6, 4, 3),
- (DEFAULT, 'La fiesta del Chivo', '9788401423276', 7.25, 504, '2000-01-01', 6, 4, 10, 1, 8, 7),
- (DEFAULT, 'Las enseñanzas de Don Juan', '9788499892627', 7.45, 288, '1968-01-01', 3, 9, 2, 5, 6, 4),
- (DEFAULT, 'Los versos satánicos', '9788490628770', 7.15, 576, '1988-09-26', 9, 5, 1, 8, 7, 3),
- (DEFAULT, 'Crónica de una muerte anunciada', '9788490628787', 7.30, 128, '1981-01-01', 2, 6, 10, 7, 4, 1),
- (DEFAULT, 'La naranja mecánica', '9788401352247', 7.60, 240, '1962-01-01', 1, 8, 6, 9, 2, 10);
Add Comment
Please, Sign In to add comment