0% ont trouvé ce document utile (0 vote)
6 vues17 pages

Dump SQL pour base de données bibliothèque

Ce document décrit la création de tables et de relations d'une base de données pour une bibliothèque. Il définit 14 tables incluant auteurs, livres, éditeurs, genres, utilisateurs et emprunts. Il établit des relations un à plusieurs et plusieurs à plusieurs entre les tables et ajoute des clés primaires et des index pour chaque table.

Traduit par

ScribdTranslations
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
6 vues17 pages

Dump SQL pour base de données bibliothèque

Ce document décrit la création de tables et de relations d'une base de données pour une bibliothèque. Il définit 14 tables incluant auteurs, livres, éditeurs, genres, utilisateurs et emprunts. Il établit des relations un à plusieurs et plusieurs à plusieurs entre les tables et ajoute des clés primaires et des index pour chaque table.

Traduit par

ScribdTranslations
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

-- Dump SQL de phpMyAdmin

4.4.14

[Link]

--

-- Serveur : [Link]

-- Temps de génération : 09-10-2015 à 05:32:44

-- Version du serveur : 5.6.26

-- Version de PHP : 5.6.12

DEFINIR SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

RÉGLER le fuseau horaire = "+00:00";

--

-- Base de données : `bibliotecaaa`

--

CRÉER UNE BASE DE DONNÉES SI ELLE N'EXISTE PAS `bibliotecaaa` EN CODAGE PAR DÉFAUT latin1 COLLATION
latin1_swedish_ci;

UTILISER `bibliotecaaa`;

-- --------------------------------------------------------

--

-- Structure de la table pour la table `auteur`

--

CRÉER TABLE SI NON EXISTE `autor` (


`id_auteur` int(3) non signé zero remplir NON NULL,

varchar(50) NON NULL

varchar(20) NON NULL

`apellido2` varchar(20) DEFAULT NULL,

`id_pays` int(3) non signé remplissage zéro PAS NULL

) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--

-- RELATIONS FOR THE TABLE `author`:

id_pays

-- id_pays

--

-- --------------------------------------------------------

--

-- Structure de tableau pour la table `autoresporlibro`

--

CRÉER TABLE SI NON EXISTE `autoresporlibro` (

`id_autor` int(3) non signé zerofill NON NULL,

`id_libro` int(3) non signé zerofill NON NULL

) MOTEUR=InnoDB Jeu de caractères par défaut=latin1;

--

-- RELATIONS FOR TABLE `autoresporlibro` :


id_auteur

-- id_autor

id_libro

-- id_libro

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `copiasporlibro`

--

CRÉER UNE TABLE S'IL N'EXISTE PAS `copiasporlibro` (

`id_libro` int(3) non signé zerofill NON NULL,

`Copia` int(3) NON NULL,

SecuenciaCopXLibro int(4) NON NULL,

`estadoPrestable` varchar(2) NOT NULL,

`prestado` varchar(2) NOT NULL,

`id_ubicación` int(3) non signé zerofill NON NULL

) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--

-- RELATIONS FOR THE TABLE `copiasporlibro`:

id_emplacement

-- id_ubicacion

--
-- --------------------------------------------------------

--

-- Structure de table pour la table `editorial`

--

CRÉER LA TABLE SI ELLE N'EXISTE PAS `editorial` (

`id_editorial` int(3) non signé zerofill NON NULL,

`nom` varchar(50) NOT NULL,

int(3) non signé zerofill NON NULL

) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--

-- RELATIONS FOR THE TABLE `editorial`:

paysÉditeur

-- id_pays

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `genre`

--

CRÉER TABLE AU CAS OÙ IL N'EXISTE PAS `genero` (


`id_genero` int(3) non signé zerofill NON NULL,

varchar(50) NON NULL

) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--

-- RELATIONS FOR THE TABLE `genre`:

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `livres`

--

CRÉER UNE TABLE SI NON EXISTE `libros` (

`id_libro` int(3) non signé zero-rempli NON NULL,

titre

`tomo` int(2) NON NULL,

`id_editorial` int(3) non signé zerofill NON NULL,

int(3) NON NUL

int(4) NON NULL

`id_genero` int(3) non signé zerofill NON NULL,

bigint(13) NON NULL

int(4) NON NULL

date NON NULL

varchar(100) NON NULL


) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--

-- RELATIONS POUR LA TABLE `libros`:

id_editorial

-- id_editorial

-- `id_gnero`

-- id_genero

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `pays`

--

CRÉER TABLE SI NON EXISTE `paises` (

`id_pays` int(3) non signé zerofill NON NULL,

varchar(50) NON NULL

) MOTEUR=InnoDB ENCODAGE_PAR_DÉFAUT=latin1;

--

-- RELATIONS FOR THE TABLE `paises`:

--

-- --------------------------------------------------------
--

-- Structure de table pour la table `prestamo`

--

CRÉER UNE TABLE SI NON EXISTE `prestamo` (

`id_prestamo` int(3) non signé zerofill NON NULL,

`id_utilisateur` int(3) unsigned zerofill NOT NULL,

int(4) NON NULL

id_tipoPrestamo

date NON NULL DEFAULT '0000-00-00'

date NON NULL DEFAULT '0000-00-00'

) MOTEUR=InnoDB DEFAULT CHARSET=latin1;

--

-- RELATIONS FOR THE TABLE `prestamo`:

id_utilisateur

-- id_utilisateur

-- `referCopiasParLivre`

SecuenciaCopXLibro

id_typeDePrêt

-- id_tipoPrestamo

--

-- --------------------------------------------------------
--

-- Structure de la table pour la table `tipodocumento`

--

CRÉER TABLE SI NON EXISTE `tipodocumento` (

`id_tipoDoc` int(3) non signé zerofill NON NULL,

varchar(50) NON NULL

Description

) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--

-- RELATIONS POUR LA TABLE `tipodocumento`:

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `tipoprestamo`

--

CRÉER TABLE IF NOT EXISTS `tipoprestamo` (

`id_tipoPrestamo` int(2) unsigned zerofill NOT NULL,

varchar(50) NON NULL

) MOTEUR=InnoDB ENCODAGE PAR DÉFAUT=latin1;

--
-- RELATIONS FOR THE TABLE `tipoprestamo`:

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `tipousuario`

--

CRÉER TABLE SI NON EXISTE `tipousuario` (

`id_tipoUtilisateur` int(2) non signé zerofill NON NULL,

`dénomination` varchar(50) NON NULL

) MOTEUR=InnoDB ENCODAGE DE CARACTÈRES PAR DÉFAUT=latin1;

--

-- RELATIONS POUR LA TABLE `tipousuario` :

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `ubicacion`

--

CREER UNE TABLE SI NON EXISTE `ubicacion` (

`id_ubicacion` int(3) non signé zerofill NON NULL,


varchar(50) NOT NULL

) MOTEUR=InnoDB ENCODAGE DE CARACTÈRES PAR DÉFAUT=latin1;

--

-- RELATIONS FOR THE TABLE `ubicacion`:

--

-- --------------------------------------------------------

--

-- Structure de la table pour la table `utilisateur`

--

CRÉER UNE TABLE S'IL N'EXISTE PAS `usuario` (

`id_utilisateur` int(3) non signé zerofill NON NULL,

`id_tipoUtilisateur` int(3) unsigned zerofill NOT NULL

nombres varchar(50) NOT NULL

`apellido1` varchar(50) NON NULL,

`apellido2` varchar(50) NON NULL,

`id_tipoDoc` int(3) non signé zerofill NON NULL,

numDoc varchar(10) NOT NULL,

int(20) NON NULL

domicile

) MOTEUR=InnoDB ENCODAGE_PAR_DÉFAUT=latin1;

--
-- RELATIONS FOR THE TABLE `usuario`:

id_tipoUtilisateur

-- id_tipoUsuario

id_typeDoc

-- id_tipoDoc

--

--

-- Indexes pour les tableaux déversés

--

--

-- Indices de la table `autor`

--

MODIFIER LA TABLE `autor`

AJOUTER UNE CLE PRIMAIRE (`id_autor`),

AJOUTER LA CLÉ `id_pais` (`id_pais`);

--

-- Indices de la table `autoresporlibro`

--

ALTER TABLE `autoresporlibro`

AJOUTER LA CLÉ PRIMAIRE (`id_autor`,`id_libro`),

AJOUTER LA CLÉ `id_libro` (`id_libro`);

--
-- Indices de la table `copiasporlibro`

--

MODIFIER LA TABLE `copiasporlibro`

AJOUTER UNE CLÉ PRIMAIRE (`id_libro`,`Copia`),

AJOUTER UNE CLÉ UNIQUE `indice` (`SecuenciaCopXLibro`),

AJOUTER LA CLÉ `id_ubicacion` (`id_ubicacion`),

AJOUTER LA CLÉ `estadoPrest` (`estadoPrestable`),

AJOUTER LA CLÉ `id_libro` (`id_libro`),

AJOUTER LA CLÉ `id_libro_2` (`id_libro`,`Copia`);

--

-- Indices de la table `editorial`

--

MODIFIER TABLE `editorial`

AJOUTER UNE CLE PRIMAIRE (`id_editorial`),

AJOUTER UNE CLÉ `paisEditorial` (`paisEditorial`);

--

-- Indices de la table `genre`

--

MODIFIER LA TABLE `genero`

AJOUTER UNE CLÉ PRIMAIRE (`id_genero`);

--

-- Indices de la table `libros`

--
MODIFIER TABLE `libros`

AJOUTER UNE CLÉ PRINCIPALE (`id_libro`),

AJOUTER LA CLÉ `id_autor_4` (`id_editorial`, `id_genero`),

AJOUTER LA CLÉ `id_genero` (`id_genero`);

--

-- Indices de la table `pays`

--

MODIFIER LA TABLE `paises`

AJOUTER UNE CLÉ PRIMAIRE (`id_pais`);

--

-- Indices de la table `prestamo`

--

MODIFIER LA TABLE `prestamo`

AJOUTER UNE CLÉ PRIMAIRE (`id_prestamo`),

AJOUTER UNE CLÉ UNIQUE `referLibro` (`referCopiasPorLibro`)

AJOUTER LA CLÉ `id_libro` (`id_usuario`, `id_tipoPrestamo`),

AJOUTER LA CLÉ `id_tipoPrestamo` (`id_tipoPrestamo`);

--

-- Indices de la table `tipodocumento`

--

MODIFIER LA TABLE `tipodocumento`

AJOUTER UNE CLÉ PRIMAIRE (`id_tipoDoc`);


--

-- Indices de la table `tipoprestamo`

--

MODIFIER LA TABLE `tipoprestamo`

AJOUTER UNE CLÉ PRIMAIRE (`id_tipoPrestamo`);

--

-- Indices de la table `tipousuario`

--

MODIFIER LA TABLE `tipousuario`

AJOUTER LA CLÉ PRIMAIRE (`id_tipoUsuario`);

--

-- Indices de la table `ubicacion`

--

MODIFIER TABLE `ubicacion`

AJOUTER UNE CLE PRIMAIRE (`id_ubicacion`);

--

-- Indices de la table `usuario`

--

MODIFIER LA TABLE `usuario`

AJOUTER UNE CLÉ PRIMAIRE (`id_usuario`),

AJOUTER LA CLÉ `id_tipoUsuario` (`id_tipoUsuario`, `id_tipoDoc`),

AJOUTER LA CLÉ `id_tipoUsuario_2` (`id_tipoUsuario`)

AJOUTER LA CLÉ `id_tipoDoc` (`id_tipoDoc`);


--

-- AUTO_INCREMENT des tables exportées

--

--

-- AUTO_INCREMENT de la table `pays`

--

MODIFIER TABLE `paises`

MODIFIER `id_pais` int(3) non signé zerofill NON NULL AUTO_INCREMENT;

--

-- Restrictions for dumped tables

--

--

-- Filtres pour la table `auteur`

--

ALTER TABLE `autor`

AJOUTER CONTRAINTE `autor_ibfk_1` CLE ÉTRANGÈRE (`id_pais`) RÉFÉRENCES `paises` (`id_pais`) ON


MISE À JOUR EN CASCADE;

--

-- Filtres pour la table `autoresporlibro`

--

MODIFIER TABLE `autoresporlibro`


AJOUTER CONTRAINTE `autoresporlibro_ibfk_1` CLÉ ÉTRANGÈRE (`id_autor`) RÉFÉRENCES `autor`
(id_auteur)

AJOUTER CONTRAINTE `autoresporlibro_ibfk_2` CLÉ ÉTRANGÈRE (`id_libro`) RÉFÉRENCE `libros`


(`id_libro`);

--

-- Filtres pour la table `copiasporlibro`

--

MODIFIER LA TABLE `copiasporlibro`

AJOUTER UNE CONTRAINTE `copiasporlibro_ibfk_1` CLÉ ÉTRANGÈRE (`id_ubicacion`) RÉFÉRENCES


`ubicacion` (`id_ubicacion`) SUR MISE À JOUR CASCADE;

--

-- Filtres pour la table `editorial`

--

MODIFIER LA TABLE `editorial`

AJOUTER UNE CONTRAINTE `editorial_ibfk_1` CLÉ ÉTRANGÈRE (`paisEditorial`) FAIT RÉFÉRENCE À `paises`
(`id_pays`);

--

-- Filtres pour la table `livres`

--

MODIFIER LA TABLE `libros`

AJOUTER UNE CONTRAINTE `libros_ibfk_1` CLÉ ÉTRANGÈRE (`id_editorial`) RÉFÉRENCE `editorial`


(`id_editorial`) SUR MISE À JOUR CASCADE,

AJOUTER UNE CONTRAINTE `libros_ibfk_2` CLÉ ÉTRANGÈRE (`id_genero`) RÉFÉRENCES `genero`


(`id_genero`) SUR MISE À JOUR CASCADE ;
--

-- Filtres pour la table `prestamo`

--

MODIFIER LA TABLE `prestamo`

AJOUTER CONTRAINTE `prestamo_ibfk_1` CLÉ ÉTRANGÈRE (`id_usuario`) RÉFÉRENCES `usuario`


(`id_usuario`) SUR MISE À JOUR CASCADE,

AJOUTER UNE CONTRAINTE `prestamo_ibfk_2` CLÉ ÉTRANGÈRE (`referCopiasPorLibro`) RÉFÈRE


`copiasporlibro` (`SecuenciaCopXLibro`) ON UPDATE CASCADE,

AJOUTER UNE CONTRAINTE `prestamo_ibfk_3` CLÉ ÉTRANGÈRE (`id_tipoPrestamo`) FAITS RÉFÉRENCE À


`tipoprestamo` (`id_tipoPrestamo`) SUR MISE À JOUR CASCADE;

--

-- Filtres pour la table `utilisateur`

--

MODIFIER TABLE `usuario`

AJOUTER CONTRAINTE `usuario_ibfk_1` CLÉ ÉTRANGÈRE (`id_tipoUsuario`) RÉFÉRENCES `tipousuario`


(`id_tipoUtilisateur`) SUR MISE À JOUR CASCADE,

AJOUTER UNE CONTRAINTE `usuario_ibfk_2` CLÉ ÉTRANGÈRE (`id_tipoDoc`) RÉFÉRENCES `tipodocumento`


(`id_tipoDoc`) ON UPDATE CASCADE;

Vous aimerez peut-être aussi