CREATE TABLE `libros` (
`id` int(10) unsigned NOT NULL,
`isbn` varchar(13) DEFAULT NULL,
`referencia` varchar(50) DEFAULT NULL COMMENT 'Código del libro en la
biblioteca',
`titulo` varchar(100) NOT NULL,
`autor` varchar(150) NOT NULL,
`departamento` varchar(50) NOT NULL COMMENT 'Dpto. dueño del libro',
`id_alumno` int(10) unsigned DEFAULT '0',
`id_profesor` int(10) unsigned DEFAULT '0',
`fecha_prestamo` date DEFAULT NULL COMMENT 'Fecha en que fue sacado de la
biblioteca',
`fecha_limite` date DEFAULT NULL COMMENT 'Fecha limite para la devolución
menor o igual que 14 días si el id_alumno no es de tipo ADJUNTO y menor o igual
que 21 días si el id_alumno es de tipo ADJUNTO y menor o igual a 35 días si el
id_profesor es no nulo',
`disponible` bit NOT NULL DEFAULT '0' COMMENT '# si es 1 es un libro
actualmente disponible para profesores y alumnos adjuntos a proyectos de
investigación',
`numero_ejemplares` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `historial_libros` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_libro` int(10) unsigned DEFAULT '0',
`id_alumno` int(10) unsigned DEFAULT '0',
`id_profesor` int(10) unsigned DEFAULT '0',
`fecha_prestamo` date DEFAULT NULL COMMENT 'Fecha en que fue sacado de la
biblioteca',
`fecha_devolucion` date DEFAULT NULL COMMENT 'Fecha en que fue devuelto a
la biblioteca',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `alumnos` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`nombre` varchar(100) NOT NULL,
`apellidos` varchar(150) NOT NULL,
`curso` int(10) unsigned NOT NULL DEFAULT '1' COMMENT 'curso en que está el
alumno (1 3)',
`libros_prestados` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '# libros
actualmente en su posesión menor o igual a 3 si el alumno es NORMAL menor o
igual a 5 si el alumno es ADJUNTO',
`tipo` bit NOT NULL DEFAULT '0' COMMENT '# tipo de alumno: 0 es NORMAL y 1
es ADJUNTO',
`libros_no_devueltos` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '#
libros actualmente no devueltos desde su último préstamo. Debe ser 0 si el
alumno quiere retirar otro libro',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `profesores` (
`id` int(10) unsigned NOT NULL,
`nombre` varchar(100) NOT NULL,
`apellidos` varchar(150) NOT NULL,
`departamento` varchar(100) NOT NULL COMMENT 'Departamento al que
pertenece',
`libros` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '# libros
actualmente en su posesión. Debe ser menor o igual a 8',
`libros_no_devueltos` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '#
libros actualmente no devueltos desde su último préstamo. Debe ser menor o igual
a 2 si el profesor quiere retirar otro libro',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1