1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
| CREATE TABLE ED_editeur(
ED_ident INT AUTO_INCREMENT,
ED_nom VARCHAR(128) NOT NULL,
PRIMARY KEY(ED_ident)
);
CREATE TABLE LG_langue(
LG_ident INT AUTO_INCREMENT,
LG_code_iso6392 CHAR(3) NOT NULL,
LG_libelle VARCHAR(50) NOT NULL,
PRIMARY KEY(LG_ident),
UNIQUE(LG_code_iso6392)
);
CREATE TABLE CO_contributeur(
CO_ident INT AUTO_INCREMENT,
CO_nom VARCHAR(50) NOT NULL,
CO_prenom VARCHAR(50) ,
PRIMARY KEY(CO_ident)
);
CREATE TABLE GE_genre(
GE_indent INT AUTO_INCREMENT,
GE_nom VARCHAR(50) NOT NULL,
PRIMARY KEY(GE_indent)
);
CREATE TABLE ET_etagere(
ET_ident INT AUTO_INCREMENT,
ET_nom VARCHAR(50) NOT NULL,
PRIMARY KEY(ET_ident)
);
CREATE TABLE FO_fonction(
FO_ident INT AUTO_INCREMENT,
FO_nom VARCHAR(25) NOT NULL,
PRIMARY KEY(FO_ident)
);
CREATE TABLE OE_oeuvre(
OE_ident INT AUTO_INCREMENT,
OE_titre VARCHAR(128) NOT NULL,
LG_ident INT NOT NULL,
PRIMARY KEY(OE_ident),
FOREIGN KEY(LG_ident) REFERENCES LG_langue(LG_ident)
);
CREATE TABLE EO_edition(
EO_ident INT AUTO_INCREMENT,
EO_date DATE NOT NULL,
EO_titre VARCHAR(128) NOT NULL,
OE_ident INT,
ED_ident INT NOT NULL,
LG_ident INT NOT NULL,
PRIMARY KEY(EO_ident),
FOREIGN KEY(OE_ident) REFERENCES OE_oeuvre(OE_ident),
FOREIGN KEY(ED_ident) REFERENCES ED_editeur(ED_ident),
FOREIGN KEY(LG_ident) REFERENCES LG_langue(LG_ident)
);
CREATE TABLE RE_recueil(
EO_ident INT,
RE_titre VARCHAR(50) NOT NULL,
PRIMARY KEY(EO_ident),
FOREIGN KEY(EO_ident) REFERENCES EO_edition(EO_ident)
);
CREATE TABLE EP_edition_possedee(
EO_ident INT,
EP_isbn VARCHAR(13) NOT NULL,
EP_resume VARCHAR(255) NOT NULL,
PRIMARY KEY(EO_ident),
FOREIGN KEY(EO_ident) REFERENCES EO_edition(EO_ident)
);
CREATE TABLE EX_exemplaire(
EO_ident INT,
EX_seqn SMALLINT,
EX_date_acq DATE NOT NULL,
etat VARCHAR(50) NOT NULL,
PRIMARY KEY(EO_ident, EX_seqn),
FOREIGN KEY(EO_ident) REFERENCES EP_edition_possedee(EO_ident)
);
CREATE TABLE TH_thematiser(
OE_ident INT,
GE_indent INT,
PRIMARY KEY(OE_ident, GE_indent),
FOREIGN KEY(OE_ident) REFERENCES OE_oeuvre(OE_ident),
FOREIGN KEY(GE_indent) REFERENCES GE_genre(GE_indent)
);
CREATE TABLE RG_ranger(
EO_ident INT,
EX_seqn SMALLINT,
CA_date DATE,
ET_ident INT NOT NULL,
PRIMARY KEY(EO_ident, EX_seqn, CA_date),
FOREIGN KEY(EO_ident, EX_seqn) REFERENCES EX_exemplaire(EO_ident, EX_seqn),
FOREIGN KEY(ET_ident) REFERENCES ET_etagere(ET_ident)
);
CREATE TABLE AS_associer(
EO_ident_enfant INT,
EO_ident_parent INT,
PRIMARY KEY(EO_ident_enfant, EO_ident_parent),
FOREIGN KEY(EO_ident_enfant) REFERENCES EP_edition_possedee(EO_ident),
FOREIGN KEY(EO_ident_parent) REFERENCES EO_edition(EO_ident)
);
CREATE TABLE CO_contenir(
OE_ident INT,
EO_ident INT,
PRIMARY KEY(OE_ident, EO_ident),
FOREIGN KEY(OE_ident) REFERENCES OE_oeuvre(OE_ident),
FOREIGN KEY(EO_ident) REFERENCES RE_recueil(EO_ident)
);
CREATE TABLE PA_participer(
OE_ident INT,
CO_ident INT,
FO_ident INT,
PRIMARY KEY(OE_ident, CO_ident, FO_ident),
FOREIGN KEY(OE_ident) REFERENCES OE_oeuvre(OE_ident),
FOREIGN KEY(CO_ident) REFERENCES CO_contributeur(CO_ident),
FOREIGN KEY(FO_ident) REFERENCES FO_fonction(FO_ident)
);
SELECT 'fin DDL'
;
-- Insertions
insert into ED_editeur (ED_nom)
values ('Gallimard')
, ('Seuil')
, ('Dargaud')
, ('Viking Press')
;
select 'ISR ED OK' ;
insert into LG_langue (LG_code_iso6392, LG_libelle)
values ('fra', 'français')
, ('eng', 'anglais')
, ('deu', 'allemand')
, ('spa', 'espagnol')
;
select 'ISR LG OK' ;
insert into OE_oeuvre (OE_titre, LG_ident)
values ('Notre-Dame de Paris', 1)
, ('Le rouge et le noir', 1)
, ('Astérix le Gaulois', 1)
, ('La serpe d''or', 1)
, ('The Rotters'' Club', 2)
, ('The Closed Circle ', 2)
;
select 'ISR OE OK' ;
insert into EO_edition (EO_date, EO_titre, OE_ident, ED_ident, LG_ident)
values ('2020-06-25', 'Notre-Dame de Paris', 1, 1, 1) -- Notre-Dame de Paris / Gallimard
, ('2015-11-03', 'Le rouge et le noir', 2, 2, 1) -- Le rouge et le noir / Seuil
, ('2022-03-18', 'Notre-Dame de Paris', 1, 2, 1) -- Notre-Dame de Paris / Seuil
, ('1961-04-12', 'Astérix le Gaulois', 3, 3, 1) -- Astérix le Gaulois / Dargaud
, ('1962-06-01', 'La serpe d''Or', 4, 3, 1) -- La serpe d'Or / Dargaud
, ('1975-01-20', 'Asterix - T1&2', null, 3, 1) -- recueil / Dargaud
, ('2001-06-01', 'The Rotters'' Club', 5, 4, 2) -- edition VO Bienvenue au club
, ('2002-06-01', 'Bienvenue au club', 5, 1, 1) -- edition VF Bienvenue au club
, ('2004-06-01', 'The Closed Circle ', 5, 4, 2) -- edition VO Le cercle fermé
, ('2006-06-01', 'Le cercle fermé', 5, 1, 1) -- edition VF Le cercle fermé
, ('2015-01-20', 'Les Enfants de Longbridge', null, 1, 1 ) -- recueil / Gallimard Bienvenue au club & Le cercle fermé
;
select 'ISR EO OK' ;
insert into RE_recueil (EO_ident, RE_titre)
values (6, 'Asterix - T1&2')
, (11, 'Les Enfants de Longbridge')
;
select 'ISR RE OK' ;
insert into CO_contenir(OE_ident, EO_ident)
values (3, 6)
, (4, 6)
, (5, 11)
, (6, 11)
; |
Partager