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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
| --------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
DROP TABLE IF EXISTS `client`
--------------
--------------
CREATE TABLE `client`
( `id_client` integer unsigned not null auto_increment primary key,
`nom` varchar(255) not null,
`prenom` varchar(255) not null,
`adresse` varchar(255) not null,
`postal` varchar(255) not null,
`ville` varchar(255) not null
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert into `client` (`nom`,`prenom`,`adresse`,`postal`,`ville`) values
('Daudet', 'Alphonse', '15 boulevard Raspail', '75006', 'Paris'),
('Blum', 'Léon', '33 rue de la Gaité', '75014', 'Paris')
--------------
--------------
select * from client
--------------
+-----------+--------+----------+----------------------+--------+-------+
| id_client | nom | prenom | adresse | postal | ville |
+-----------+--------+----------+----------------------+--------+-------+
| 1 | Daudet | Alphonse | 15 boulevard Raspail | 75006 | Paris |
| 2 | Blum | Léon | 33 rue de la Gaité | 75014 | Paris |
+-----------+--------+----------+----------------------+--------+-------+
--------------
DROP TABLE IF EXISTS `offre`
--------------
--------------
CREATE TABLE `offre`
( `id_offre` integer unsigned not null auto_increment primary key,
`detail` varchar(255) not null
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert into `offre` (`id_offre`,`detail`) values
(10,'Mutualisé N°1'),(11,'Mutualisé N°2'),(12,'Mutualisé N°3'),
(20,'VPS N°1'), (21,'VPS N°2'), (22,'VPS N°3'),
(30,'SeedBox N°1'), (31,'SeedBox N°2'), (32,'SeedBox N°3'), (33,'SeedBox N°4')
--------------
--------------
select * from offre
--------------
+----------+---------------+
| id_offre | detail |
+----------+---------------+
| 10 | Mutualisé N°1 |
| 11 | Mutualisé N°2 |
| 12 | Mutualisé N°3 |
| 20 | VPS N°1 |
| 21 | VPS N°2 |
| 22 | VPS N°3 |
| 30 | SeedBox N°1 |
| 31 | SeedBox N°2 |
| 32 | SeedBox N°3 |
| 33 | SeedBox N°4 |
+----------+---------------+
--------------
DROP TABLE IF EXISTS `mutualise`
--------------
--------------
CREATE TABLE `mutualise`
( `id_mutualise` integer unsigned not null primary key,
`capacite` varchar(255) not null,
CONSTRAINT `FK_MUTUALISE` FOREIGN KEY (`id_mutualise`) REFERENCES `offre` (`id_offre`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert into `mutualise` (`id_mutualise`,`capacite`) values
(10, 'détail capacité mutualisé N°1'),
(11, 'détail capacité mutualisé N°2'),
(12, 'détail capacité mutualisé N°3')
--------------
--------------
select * from mutualise
--------------
+--------------+-------------------------------+
| id_mutualise | capacite |
+--------------+-------------------------------+
| 10 | détail capacité mutualisé N°1 |
| 11 | détail capacité mutualisé N°2 |
| 12 | détail capacité mutualisé N°3 |
+--------------+-------------------------------+
--------------
DROP TABLE IF EXISTS `vps`
--------------
--------------
CREATE TABLE `vps`
( `id_vps` integer unsigned not null primary key,
`processeur` varchar(255) not null,
CONSTRAINT `FK_VPS` FOREIGN KEY (`id_vps`) REFERENCES `offre` (`id_offre`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert into `vps` (`id_vps`,`processeur`) values
(20, 'détail processeur VPS N°1'),
(21, 'détail processeur VPS N°2'),
(22, 'détail processeur VPS N°3')
--------------
--------------
select * from vps
--------------
+--------+---------------------------+
| id_vps | processeur |
+--------+---------------------------+
| 20 | détail processeur VPS N°1 |
| 21 | détail processeur VPS N°2 |
| 22 | détail processeur VPS N°3 |
+--------+---------------------------+
--------------
DROP TABLE IF EXISTS `seedbox`
--------------
--------------
CREATE TABLE `seedbox`
( `id_seedbox` integer unsigned not null primary key,
`cloud` varchar(255) not null,
CONSTRAINT `FK_seedbox` FOREIGN KEY (`id_seedbox`) REFERENCES `offre` (`id_offre`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert into `seedbox` (`id_seedbox`,`cloud`) values
(30, 'détail cloud seedbox N°1'),
(31, 'détail cloud seedbox N°2'),
(32, 'détail cloud seedbox N°3')
--------------
--------------
select * from seedbox
--------------
+------------+--------------------------+
| id_seedbox | cloud |
+------------+--------------------------+
| 30 | détail cloud seedbox N°1 |
| 31 | détail cloud seedbox N°2 |
| 32 | détail cloud seedbox N°3 |
+------------+--------------------------+
--------------
DROP TABLE IF EXISTS `associative`
--------------
--------------
CREATE TABLE `associative`
( `id_associative` integer unsigned not null auto_increment primary key,
`id_client` integer unsigned not null,
`id_offre` integer unsigned not null,
`inscription` date not null,
CONSTRAINT `FK_associative_client` FOREIGN KEY (`id_client`) REFERENCES `client` (`id_client`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_associative_offre` FOREIGN KEY (`id_offre`) REFERENCES `offre` (`id_offre`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert into `associative` (`id_client`,`id_offre`,`inscription`) values
(1, 21, '2015-07-14'),
(2, 12, '2015-09-23'),
(2, 32, '2015-07-25')
--------------
--------------
select * from associative
--------------
+----------------+-----------+----------+-------------+
| id_associative | id_client | id_offre | inscription |
+----------------+-----------+----------+-------------+
| 1 | 1 | 21 | 2015-07-14 |
| 2 | 2 | 12 | 2015-09-23 |
| 3 | 2 | 32 | 2015-07-25 |
+----------------+-----------+----------+-------------+
--------------
select c.id_client,
c.nom,
c.prenom,
a.id_offre,
m.capacite,
v.processeur,
s.cloud
from associative as a
inner join client as c
on a.id_client = c.id_client
inner join offre as o
on o.id_offre = a.id_offre
left outer join mutualise as m
on m.id_mutualise = a.id_offre
left outer join vps as v
on v.id_vps = a.id_offre
left outer join seedbox as s
on s.id_seedbox = a.id_offre
--------------
+-----------+--------+----------+----------+-------------------------------+---------------------------+--------------------------+
| id_client | nom | prenom | id_offre | capacite | processeur | cloud |
+-----------+--------+----------+----------+-------------------------------+---------------------------+--------------------------+
| 1 | Daudet | Alphonse | 21 | NULL | détail processeur VPS N°2 | NULL |
| 2 | Blum | Léon | 12 | détail capacité mutualisé N°3 | NULL | NULL |
| 2 | Blum | Léon | 32 | NULL | NULL | détail cloud seedbox N°3 |
+-----------+--------+----------+----------+-------------------------------+---------------------------+--------------------------+
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 1
--------------
Appuyez sur une touche pour continuer... |
Partager