Está en la página 1de 5

create database db_Biblioteca

use db_Biblioteca

create table carreras(


id int identity NOT NULL primary key,
nombre varchar(100) NOT NULL,
cantidad_ciclos int NOT NULL,
aos int NOT NULL,
sitio_web varchar(45) NOT NULL,
estado int NOT NULL,
)

create table alumnos(


id int identity(0,1) not null primary key,
codigo varchar(45) NOT NULL,
nombre varchar(100) NOT NULL,
ap_paterno varchar(100) NOT NULL,
ap_materno varchar(100) NOT NULL,
especialidad varchar(100) NOT NULL,
sexo varchar(1) NOT NULL,
turno varchar(40) NOT NULL,
celular varchar(15) NOT NULL,
id_carrera int,
CONSTRAINT FK_alumnos_idcarreras FOREIGN KEY (id_carrera) REFERENCES carreras(id)
)

create table docentes(


id int identity(0,1) NOT NULL primary key,
nombre varchar(100) NOT NULL,
id_carrera int,
CONSTRAINT FK_decentes_idcarreras FOREIGN KEY (id_carrera) REFERENCES
carreras(id)
)

create table empleados(


id int identity NOT NULL primary key,
nombre varchar(100) NOT NULL,
apellido varchar(100) NOT NULL,
)

create table especialidades(


id int identity NOT NULL primary key,
nombre varchar(100) NOT NULL,
id_carrera int,
CONSTRAINT FK_especialidades_idcarreras FOREIGN KEY (id_carrera) REFERENCES
carreras(id)
)

create table libros(


id int identity NOT NULL primary key,
codigo varchar(255) NOT NULL,
titulo_libro text,
autor_libro text,
pais varchar(100) NOT NULL,
editorial text,
edicion varchar(255) NOT NULL,
ano int NOT NULL,
fecha_adquisicion date NOT NULL
)

create table catalogos(


id int identity NOT NULL primary key,
codigo varchar(100) NOT NULL,
id_carrera int,
id_especialidad int,
id_libro int,
CONSTRAINT FK_catalogos_idcarreras FOREIGN KEY (id_carrera) REFERENCES
carreras(id),
CONSTRAINT FK_catalogos_idespecialidades FOREIGN KEY (id_especialidad) REFERENCES
especialidades(id),
CONSTRAINT FK_catalogos_idlibros FOREIGN KEY (id_libro) REFERENCES libros(id)
)

create table usuarios(


id int identity NOT NULL primary key,
id_empleado int,
usuario varchar(50) NOT NULL,
password varchar(50) NOT NULL,
CONSTRAINT FK_usuarios_idempleados FOREIGN KEY (id_empleado) REFERENCES
empleados(id)
)

create table prestamos(


id int identity NOT NULL primary key,
fecha_prestamos date NOT NULL,
hora_prestamo time NOT NULL,
fecha_devolucion date NOT NULL,
hora_devolucion time NOT NULL,
estado int NOT NULL,
id_libro int,
id_alumno int,
id_docente int,
id_usuario int,
CONSTRAINT FK_prestamos_idlibros FOREIGN KEY (id_libro) REFERENCES libros(id),
CONSTRAINT FK_prestamos_idalumnos FOREIGN KEY (id_alumno) REFERENCES alumnos(id),
CONSTRAINT FK_prestamos_iddocentes FOREIGN KEY (id_docente) REFERENCES
docentes(id),
CONSTRAINT FK_prestamos_idusuarios FOREIGN KEY (id_usuario) REFERENCES
usuarios(id)
)

INSERT INTO carreras VALUES ('Administracion de


Empresas',10,5,'www.adm.undc.edu.pe',1),
('Agronomia',10,5,'www.agronomia.undc.edu.pe',1),
('Contabilidad',10,5,'www.Contabilidad.undc.edu.pe',1),
('Ingenieria de Sistemas',10,5,'www.sistemas.undc.edu.pe',1),
('Turismo y hoteleria',10,5,'www.turismo.undc.edu.pe',1),
('Nulo',0,0,'-',0)

INSERT INTO alumnos VALUES ('-','-','-','-','-','-','-','-',6),


('1423754114','ANGELES','ANTEQUERA','CHAMIZO','DESARROLLO DE
SOFTWARE','F','TARDE','985456712',4),
('1412341527','JOSE','CASTELLO','PINO','MERCADO DE
CAPITALES','M','MANANA','910123647',1),
('1524146237','CARLOS','GONZALES','MENDOZA','CONTABILIDAD
BANCARIA','M','TARDE','912033604',2),
('1423164512','SOFIA','PRIEGO','DUARTE','PLANIFICACION Y DESARROLLO
TURISTICO','F','MANANA','954611203',3),
('1412397852','DANIEL','CARDOSO','CAMARENO','REDES DE
COMUNICACIONES','M','MANANA','945410244',4),
('1421879642','ANDREA ','DOMINGUEZ','ROMERO','CONTABILIDAD
FINANCIERA','F','MANANA','976641231',2),
('1518287462','MARIA','BARROS','JARA','ADMINISTRACION DE
EMPRESAS','F','TARDE','976548412',3),

('1589737389','ANTONIO','UBEDA','RIOJA','FRUTICULTURA','M','MANANA','978874510',5),
('1543876428','RUBEN ','NAVARRO','IRIARTE','SISTEMAS DE
INFORMACION','M','TARDE','956120525',4),
('1412738791','RAFAEL','MORANT','RICO','EVALUACION DE PROYECTOS DE
INVERSION','M','MANANA','997946412',1),

('1423978224','ANA','BARRAGAN','VIERA','BIOTECNOLOGIA','F','TARDE','999746010',5),
('1523124625','MONICA','ZAMORA','HUAMAN','CONTABLIDAD DE
SERVICIOS','F','MANANA','901461121',2),
('1578564231','CAMILA','PARDO','SANCHEZ','GESTION ESTRATEGICA DE
MARKETING','F','MANANA','913243077',3),
('1489786453','PABLO','LLANOS','ISLAS','DESARROLLO DE
SOFTWARE','M','TARDE','997784645',4)

INSERT INTO docentes VALUES ('nulo',6),


('Gardyn Olivera Ruiz',2),
('Victor Arce',3),('Frankli Arriola',4),
('David Quevedo',5),('Renee Rivera',1)

INSERT INTO empleados VALUES ('MIRIAM','SANCHEZ'),


('PILAR','LLANOS'),('CARLOS','BARRAGAN'),
('CARLA','ISLAS'),('EMILIA','ROMERO'),('MARCOS','SALAS')

INSERT INTO especialidades VALUES ('BIOLOGIA',2),


('DICCIONARIOS TECNICOS Y GUIAS PRACTICAS',2),
('FISICA',2),('QUIMICA',2),('TIPOS DE PLANTAS - ENFERMEDADES',2),
('CONTABILIDAD',3),('ADMINISTRACION',1)

INSERT INTO libros VALUES ('333/7/A91/2007','Gestion','Alfonso Avellaneda


Cusaria','Colombia','Ecoe Ediciones','Segunda',2009,'2014-01-01'),
('333/7/C29','Energia','Xavier Elias Castells/Santiago','Espana','Editorial Diaz
de Santos','Primera',2011,'2014-01-02'),
('354/36/F223','El Derecho al Agua','Farhana Sultana Alex
Loftus','Mexico','Editorial Trillas SAc','Primera',2014,'2014-01-03'),
('540/92/O71','Contaminacion Ambiental','Carmen Orozco Barrenetxea y
otros','Espana','Ediciones Paraninfo SA','Primera',2011,'2014-01-04'),
('551/6/V864/2010','Cambios climaticos Tecnologias','Manuel Vizcarra
Andreu','Peru','ARS Asesoria y Servicios SAC','Primera',2010,'2014-01-05'),
('561/9/S211','Setas Comestibles y toxicas diferencias ','Juan Antonio Sanchez
Rodriguez','Espana','Ediciones Mundi Prensa','Primera',2012,'2014-01-06'),
('561/92/C165','Setas - hongos','Francisco de Diego Calonge','Espana','Ediciones
Mundi Prensa','Segunda',1990,'2014-01-07'),
('570/1/D278','Biologia la ciencia de la vida','Elene De Erice/ Arturo
Gonzales','Mexico','McGraw Hill Interamecicana Editores S/A','Segunda',2012,'2014-
01-08'),
('570/C95/2011','Biologia','Helena Curtis','Argentina','Editorial Medica
Panamerciana sACF','Septima',2011,'2014-01-09'),
('570/G79','Biologia General','Pilar Granillo/ Blanca Valdivia/ Maria del Socorro
Villareal','Mexico','Grupo Editorial Patria S/A','Primera',2011,'2014-01-10'),
('571/2/S689','Biologia','Solomon Berg Martin','Mexico','Cengace Learning
Editores SAc','Novena',2012,'2014-01-11'),
('571/6/P45','Biologia Celular en la ciencias Agropecuarias','Maria Alejandra
Perez','Argentina','Editorial Brujas','Primera',2012,'2014-01-12'),
('571/6/S796/2013','Biologia','Cicie Starr/ Christine Evers / Lisa
Starr','Mexico','Cengace Learning Editores S/A','Octava',2013,'2014-01-13'),
('574/K23/2011','Biologia Celular y Molecular','Gerald Karp','Mexico','McGraw
Hill Interamecicana Editores SA','Sexta',2010,'2014-01-14'),
('576/54/B928','Para que sirven los transgenicos?','David Bueno I
Torrens','Espana','Ediciones de la Universidad de Barcelona','Primera',2011,'2014-
01-15'),
('577/1/F825','Manual de ecologia','Jonathan Franco Lopez y
Coautores','Mexico','Editorial Trillas SA','Primera',2010,'2014-01-16'),
('577/2/S572','Calidad del Agua','Carlos Alberto Sierra
Ramirez','Colombia','Edicioines de la U','Primera',2011,'2014-01-17'),
('577/3/V722','Introduccion a la Botanica Forestal','Jose angel Villareal
Quintanilla','Mexico','Editorial Trillas SAC','Tercera',2006,'2014-01-18'),
('577/B797','Ecologia del Peru','Antonio Brack Egg/ Cecilia Mendiola
Vargas','Peru','Asociacion Editorial Bruno','Tercera',2010,'2014-01-19'),
('001.42/C669','Manual de procedimientos ','Consejo de asuntos contenciosos
universitarios','Peru','Business Support Aneth S.R.L','Primera',2012,'2015-02-02'),
('005.84/M760','Tecnicas de Marketing Viral','Miguel angel Montanes del Rio
','Espana','Esic Editorial','Primera',2014,'2015-02-03'),
('028.7/V712','Manual de Coaching','Juan Pablo Villa','Espana','Editorial
Profit','Primera',2010,'2015-02-04'),
('158.4/B238','El ciclo del Liderazgo','Erasmo Barbosa Cano','Mexico','Grupo
Vanchri','Primera',2014,'2015-02-05'),
('302.2/C89','Protocolo y Comunicacion en la Empresa ','Carmen Cuadrado
Esclapez','Espana','Editorial FC','Septima',2011,'2015-02-06'),
('330.6/A543/2014','Proyectos de Inversion','Walter Andia
Valencia','Peru','Ediciones Arte Pluma','Cuarta',2014,'2015-02-07'),
('333.2/A283/2014','Tratado para Administrar los agronegocios','Aguilar Valdes
Alfredo','Mexico','Editorial Limusa S.A','sexta',2014,'2015-02-08'),
('341.754/B452','Conozca el Nuevo Marketing','Jose Luis Belio/Ana Sainz
Andres','Espana','Wolters Kluwer Espana S.A','Primera',2007,'2015-02-09'),
('344.01/E796','Regimen laboral en las Mypes','Maria Estela Pina','Argentina','La
Ley S.A.E.','Primera',2011,'2015-02-10'),
('346.07/Z27','Manual de Derecho comercial','Juan Jose Zandrino','Argentina','La
Ley S.A.E.','Segunda',2011,'2015-02-11'),
('352.2/A543/2014','Manual de Gestion Publica','Walter Andia
Valencia','Peru','Evolution Graphic','cuarta',2014,'2015-01-05'),
('658.01/H174','Administracion Matricial','Kevan Hall','Mexico','Grupo Editorial
Patria S.A.','Primera',2014,'2015-02-18'),
('658.01/M688','Administracion ','Mochon Mochon Saez','Mexico','Alfaomega Grupo
Editor S.A','Primera',2014,'2015-02-19'),
('658.02/L82/2012','Administracion empresas','Justin G','Mexico','Learning
Editores S.A','Primera',2012,'2015-02-20'),
('658.02/V619','Los principios exitosos de la Direccion de Empresas','Eric
Viardot','Espana','Profit Editorial Inmobiliarias S.L','Primera',2014,'2015-02-
21'),
('658.04/G21','Administracion Estrategica','Jose Ramon Gallardo
Hernandez','Mexico','Alfaomega Grupo Editor S.A','Primera',2012,'2015-02-22'),
('658.04/H651/2014','Empredimiento e Innovacion','Julia Esther Hilarion
Madariaga','Mexico','Cengace Learning Editores','Primera',2014,'2015-02-23')

INSERT INTO catalogos VALUES ('333/7/A91/2007',2,1,1),('333/7/C29',2,2,2),


('354/36/F223',2,3,3),('540/92/O71',2,4,4),('551/6/V864/2010',2,2,5),
('561/9/S211',2,1,6),('561/92/C165',2,2,7),('570/1/D278',2,3,8),
('570/C95/2011',2,4,9),('570/G79',2,2,10),('571/2/S689',2,1,11),
('571/6/P45',2,4,12),('571/6/S796/2013',2,2,13),('574/K23/2011',2,3,14),
('576/54/B928',2,1,15),('577/1/F825',2,2,16),('577/2/S572',2,1,17),
('577/3/V722',2,4,18),('577/B797',2,4,19),('001.42/C669',1,7,20),
('005.84/M760',1,7,21),('028.7/V712',1,7,22),('158.4/B238',1,7,23),
('302.2/C89',1,7,24),('330.6/A543/2014',1,7,25),('333.2/A283/2014',1,7,26),
('341.754/B452',1,7,27),('344.01/E796',1,7,28),('346.07/Z27',1,7,29),
('658.01/H174',1,7,30),('658.01/M688',1,7,31),('658.02/L82/2012',1,7,32),
('658.02/V619',1,7,33),('658.04/G21',1,7,34),('658.04/H651/2014',1,7,35)

INSERT INTO usuarios VALUES (1,'Jramos','qwerty'),(2,'Vrojas','5tgbnhy'),


(3,'Mcampos','ertetew'),(4,'Nsalvador','sd4r85df')

INSERT INTO prestamos VALUES ('2016-01-01','08:00','2016-01-


01','11:00',1,15,1,0,1),
('2016-01-01','09:00','2016-01-01','15:00',1,20,3,0,1),
('2016-01-01','10:00','2016-01-01','16:00',1,32,13,0,1),
('2016-01-01','11:00','2016-01-01','14:30',2,34,12,0,2),
('2016-01-01','08:00','2016-01-01','12:00',1,1,10,0,2),
('2016-02-01','09:00','2016-02-01','13:00',1,4,11,0,2),
('2016-01-01','11:00','2016-01-01','13:00',2,5,7,0,3),
('2016-03-01','12:00','2016-03-01','15:00',1,6,5,0,3),
('2016-04-01','10:00','2016-04-01','17:00',1,7,14,0,3),
('2016-04-01','11:00','2016-04-01','15:00',1,11,0,4,1),
('2016-05-01','11:00','2016-05-01','13:00',1,12,0,2,1),
('2016-01-01','10:00','2016-01-01','12:00',1,13,0,1,1),
('2016-01-01','08:00','2016-01-01','13:00',1,16,0,2,2)

select * from catalogos


select * from libros
select * from prestamos
select * from alumnos
select * from usuarios
select * from empleados
select * from carreras
select * from docentes
select * from especialidades

También podría gustarte