File: ex17.sql

package info (click to toggle)
pgformatter 5.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,964 kB
  • sloc: sql: 186,493; perl: 5,694; makefile: 2; sh: 1
file content (749 lines) | stat: -rw-r--r-- 17,380 bytes parent folder | download | duplicates (5)
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
--
-- PostgreSQL database dump
--

-- Dumped from database version 9.6.2
-- Dumped by pg_dump version 9.6.2

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


SET search_path = public, pg_catalog;

--
-- Name: add(integer, integer); Type: FUNCTION; Schema: public; Owner: gilles
--

CREATE FUNCTION add(integer, integer) RETURNS integer
    LANGUAGE sql IMMUTABLE STRICT
    AS $_$select $1 + $2;$_$;


ALTER FUNCTION public.add(integer, integer) OWNER TO gilles;

--
-- Name: check_password(text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: gilles
--

CREATE FUNCTION check_password(uname1 text, pass1 text, uname2 text, pass2 text, uname3 text, pass3 text, uname4 text, pass4 text, uname5 text, pass5 text, uname6 text, pass6 text, uname7 text, pass7 text, uname8 text, pass8 text, uname9 text, pass9 text) RETURNS boolean
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO admin, pg_temp
    AS $_$
DECLARE passed BOOLEAN;
BEGIN
        SELECT  (pwd = $2) INTO passed
        FROM    pwds
        WHERE   username = $1;

        RETURN passed;
END;
$_$;


ALTER FUNCTION public.check_password(uname1 text, pass1 text, uname2 text, pass2 text, uname3 text, pass3 text, uname4 text, pass4 text, uname5 text, pass5 text, uname6 text, pass6 text, uname7 text, pass7 text, uname8 text, pass8 text, uname9 text, pass9 text) OWNER TO gilles;

--
-- Name: dup(integer); Type: FUNCTION; Schema: public; Owner: gilles
--

CREATE FUNCTION dup(integer, OUT f1 integer, OUT f2 text) RETURNS record
    LANGUAGE sql
    AS $_$ SELECT $1, CAST($1 AS text) || ' is text' $_$;


ALTER FUNCTION public.dup(integer, OUT f1 integer, OUT f2 text) OWNER TO gilles;

--
-- Name: increment(integer); Type: FUNCTION; Schema: public; Owner: gilles
--

CREATE FUNCTION increment(i integer) RETURNS integer
    LANGUAGE plpgsql
    AS $$
        BEGIN
                RETURN i + 1;
        END;
$$;


ALTER FUNCTION public.increment(i integer) OWNER TO gilles;

--
-- Name: peuple_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: userdb
--

CREATE FUNCTION peuple_stock(annee_debut integer, annee_fin integer) RETURNS bigint
    LANGUAGE plpgsql
    AS $$
DECLARE
	v_annee integer;
	v_nombre integer;
	v_contenant_id integer;
	v_vin_id integer;
	compteur bigint :=0;
	annees integer;
	contenants integer;
	vins integer;
	tuples_a_generer integer;

BEGIN

  -- vider la table de stock
  truncate table stock;

  -- calculer le nombre d'annees 
  select (annee_fin-annee_debut)+1 into annees;

  -- nombre de contenants
  select count(*) from contenant into contenants;

  -- nombre de vins
  select count(*) from vin into vins;

  -- calcul des combinaisons
  select annees*contenants*vins into tuples_a_generer;
 
  --on boucle sur tous les millesimes: disons 1930 a 2000
  -- soit 80 annees
  for v_annee in annee_debut .. annee_fin loop

    -- on boucle sur les contenants possibles
    for v_contenant_id in 1 .. contenants loop
  
       -- idem pour l'id du vin
      for v_vin_id in 1 .. vins loop
  
        -- on prends un nombre de bouteilles compris entre 6 et 18
        select round(random()*12)+6
        into v_nombre;
  
        -- insertion dans la table de stock
        insert into stock (vin_id, contenant_id, annee, nombre)
        values (v_vin_id, v_contenant_id, v_annee, v_nombre);
  
        if (((compteur%1000)=0) or (compteur=tuples_a_generer)) then
          raise notice 'stock : % sur % tuples generes', compteur, tuples_a_generer;
        end if;
 
        compteur := compteur + 1;
   
      end loop; --fin boucle vin
  
    end loop; -- fin boucle contenant

  end loop; --fin boucle annee

  RETURN compteur;

END;
$$;


ALTER FUNCTION public.peuple_stock(annee_debut integer, annee_fin integer) OWNER TO userdb;

--
-- Name: peuple_vin(); Type: FUNCTION; Schema: public; Owner: userdb
--

CREATE FUNCTION peuple_vin() RETURNS bigint
    LANGUAGE plpgsql
    AS $$
DECLARE
	v_recoltant_id integer;
	v_appellation_id integer;
	v_type_vin_id integer;
	recoltants integer;
	appellations integer;
	types_vins integer;
	tuples_a_generer integer;
	compteur bigint :=0;
BEGIN

  -- vider la table de stock, qui depend de vin, puis vin
  delete from stock;
  delete from vin;

  -- compter le nombre de recoltants
  select count(*) from recoltant into recoltants;

  -- compter le nombre d'appellations
  select count(*) from appellation into appellations;

  -- compter le nombre de types de vins
  select count(*) from type_vin into types_vins;

  -- calculer le nombre de combinaisons possibles
  select (recoltants*appellations*types_vins) into tuples_a_generer;

  --on boucle sur tous les recoltants
  for v_recoltant_id in 1 .. recoltants loop

    -- on boucle sur les appelations
    for v_appellation_id in 1 .. appellations loop
  
       -- on boucle sur les types de vins
      for v_type_vin_id in 1 .. types_vins loop
  
        -- insertion dans la table de vin
        insert into vin (recoltant_id, appellation_id, type_vin_id)
        values (v_recoltant_id, v_appellation_id, v_type_vin_id);

        if (((compteur%1000)=0) or (compteur=tuples_a_generer)) then
          raise notice 'vins : % sur % tuples generes', compteur, tuples_a_generer;
        end if;
  
        compteur := compteur + 1;
   
      end loop; --fin boucle type vin
  
    end loop; -- fin boucle appellations

  end loop; --fin boucle recoltants

  RETURN compteur;
END;
$$;


ALTER FUNCTION public.peuple_vin() OWNER TO userdb;

--
-- Name: trous_stock(); Type: FUNCTION; Schema: public; Owner: userdb
--

CREATE FUNCTION trous_stock() RETURNS bigint
    LANGUAGE plpgsql
    AS $$
DECLARE
	stock_total integer;
	echantillon integer;
	vins_disponibles integer;
	contenants_disponibles integer;
	v_vin_id integer;
	v_contenant_id integer;
	v_tuples bigint := 0;
	annee_min integer;
	annee_max integer;
	v_annee integer;
BEGIN

  -- on compte le nombre de tuples dans stock
  select count(*) from stock into stock_total;
  raise NOTICE 'taille du stock %', stock_total;

  -- on calcule la taille de l'echantillon a
  -- supprimer de la table stock
  select round(stock_total/10) into echantillon;
  raise NOTICE 'taille de l''echantillon %', echantillon;

  -- on compte le nombre de vins disponibles
  select count(*) from vin into vins_disponibles;
  raise NOTICE '% vins disponibles', vins_disponibles;

  -- on compte le nombre de contenants disponibles
  select count(*) from contenant into contenants_disponibles;
  raise NOTICE '% contenants disponibles', contenants_disponibles;

  -- on recupere les bornes min/max de annees
  select min(annee), max(annee) 
  from stock
  into annee_min, annee_max;

  -- on fait une boucle correspondant a 1% des tuples 
  -- de la table stock
  for v_tuples in 1 .. echantillon loop
   
     -- selection d'identifiant, au hasard
     --select round(random()*contenants_disponibles) into v_contenant_id;
     v_contenant_id := round(random()*contenants_disponibles);

     --select round(random()*vins_disponibles) into v_vin_id;
     v_vin_id := round(random()*vins_disponibles);

     v_annee := round(random()*(annee_max-annee_min))+(annee_min);
 
     -- si le tuple est deja efface, ce n'est pas grave..
     delete 
     from stock
     where 
           contenant_id = v_contenant_id
       and vin_id = v_vin_id
       and annee  = v_annee;

     if (((v_tuples%100)=0) or (v_tuples=echantillon)) then
       raise notice 'stock : % sur % echantillon effaces',v_tuples, echantillon;
     end if;

  end loop; --fin boucle v_tuples

  RETURN echantillon;

END;
$$;


ALTER FUNCTION public.trous_stock() OWNER TO userdb;

--
-- Name: trous_vin(); Type: FUNCTION; Schema: public; Owner: userdb
--

CREATE FUNCTION trous_vin() RETURNS bigint
    LANGUAGE plpgsql
    AS $$
DECLARE
	vin_total integer;
	echantillon integer;
	v_vin_id integer;
	v_tuples bigint := 0;
	v_annee integer;
BEGIN

  -- on compte le nombre de tuples dans vin
  select count(*) from vin into vin_total;
  raise NOTICE '% vins disponibles', vin_total;

  -- on calcule la taille de l'echantillon a
  -- supprimer de la table vin
  select round(vin_total/10) into echantillon;
  raise NOTICE 'taille de l''echantillon %', echantillon;

  -- on fait une boucle correspondant a 10% des tuples 
  -- de la table vin
  for v_tuples in 1 .. echantillon loop
   
     -- selection d'identifiant, au hasard
     v_vin_id := round(random()*vin_total);
 
     -- si le tuple est deja efface, ce n'est pas grave..

     -- TODO remplacer ce delete par un trigger on delete cascade
     --      voir dans druid le schema???
     delete 
     from stock
     where vin_id = v_vin_id;

     delete
     from vin
     where id = v_vin_id;

     if (((v_tuples%100)=0) or (v_tuples=echantillon)) then
        raise notice 'vin : % sur % echantillon effaces',v_tuples, echantillon;
     end if;

  end loop; --fin boucle v_tuples

  RETURN echantillon;

END;
$$;


ALTER FUNCTION public.trous_vin() OWNER TO userdb;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: appellation; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE appellation (
    id integer NOT NULL,
    libelle text NOT NULL,
    region_id integer
)
WITH (autovacuum_enabled=off);


ALTER TABLE appellation OWNER TO userdb;

--
-- Name: appellation_id_seq; Type: SEQUENCE; Schema: public; Owner: userdb
--

CREATE SEQUENCE appellation_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE appellation_id_seq OWNER TO userdb;

--
-- Name: appellation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: userdb
--

ALTER SEQUENCE appellation_id_seq OWNED BY appellation.id;


--
-- Name: contenant; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE contenant (
    id integer NOT NULL,
    contenance real NOT NULL,
    libelle text
)
WITH (autovacuum_enabled=off, fillfactor='20');


ALTER TABLE contenant OWNER TO userdb;

--
-- Name: contenant_id_seq; Type: SEQUENCE; Schema: public; Owner: userdb
--

CREATE SEQUENCE contenant_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE contenant_id_seq OWNER TO userdb;

--
-- Name: contenant_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: userdb
--

ALTER SEQUENCE contenant_id_seq OWNED BY contenant.id;


--
-- Name: recoltant; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE recoltant (
    id integer NOT NULL,
    nom text,
    adresse text
)
WITH (autovacuum_enabled=off);


ALTER TABLE recoltant OWNER TO userdb;

--
-- Name: recoltant_id_seq; Type: SEQUENCE; Schema: public; Owner: userdb
--

CREATE SEQUENCE recoltant_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE recoltant_id_seq OWNER TO userdb;

--
-- Name: recoltant_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: userdb
--

ALTER SEQUENCE recoltant_id_seq OWNED BY recoltant.id;


--
-- Name: region; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE region (
    id integer NOT NULL,
    libelle text NOT NULL
)
WITH (autovacuum_enabled=off);


ALTER TABLE region OWNER TO userdb;

--
-- Name: region_id_seq; Type: SEQUENCE; Schema: public; Owner: userdb
--

CREATE SEQUENCE region_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE region_id_seq OWNER TO userdb;

--
-- Name: region_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: userdb
--

ALTER SEQUENCE region_id_seq OWNED BY region.id;


--
-- Name: stock; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE stock (
    vin_id integer NOT NULL,
    contenant_id integer NOT NULL,
    annee integer NOT NULL,
    nombre integer NOT NULL
)
WITH (autovacuum_enabled=off);


ALTER TABLE stock OWNER TO userdb;

--
-- Name: type_vin; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE type_vin (
    id integer NOT NULL,
    libelle text NOT NULL
)
WITH (autovacuum_enabled=off);


ALTER TABLE type_vin OWNER TO userdb;

--
-- Name: type_vin_id_seq; Type: SEQUENCE; Schema: public; Owner: userdb
--

CREATE SEQUENCE type_vin_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE type_vin_id_seq OWNER TO userdb;

--
-- Name: type_vin_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: userdb
--

ALTER SEQUENCE type_vin_id_seq OWNED BY type_vin.id;


--
-- Name: vin; Type: TABLE; Schema: public; Owner: userdb
--

CREATE TABLE vin (
    id integer NOT NULL,
    recoltant_id integer,
    appellation_id integer NOT NULL,
    type_vin_id integer NOT NULL
)
WITH (autovacuum_enabled=off);


ALTER TABLE vin OWNER TO userdb;

--
-- Name: vin_id_seq; Type: SEQUENCE; Schema: public; Owner: userdb
--

CREATE SEQUENCE vin_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE vin_id_seq OWNER TO userdb;

--
-- Name: vin_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: userdb
--

ALTER SEQUENCE vin_id_seq OWNED BY vin.id;


--
-- Name: appellation id; Type: DEFAULT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY appellation ALTER COLUMN id SET DEFAULT nextval('appellation_id_seq'::regclass);


--
-- Name: contenant id; Type: DEFAULT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY contenant ALTER COLUMN id SET DEFAULT nextval('contenant_id_seq'::regclass);


--
-- Name: recoltant id; Type: DEFAULT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY recoltant ALTER COLUMN id SET DEFAULT nextval('recoltant_id_seq'::regclass);


--
-- Name: region id; Type: DEFAULT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY region ALTER COLUMN id SET DEFAULT nextval('region_id_seq'::regclass);


--
-- Name: type_vin id; Type: DEFAULT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY type_vin ALTER COLUMN id SET DEFAULT nextval('type_vin_id_seq'::regclass);


--
-- Name: vin id; Type: DEFAULT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY vin ALTER COLUMN id SET DEFAULT nextval('vin_id_seq'::regclass);


--
-- Name: appellation appellation_libelle_key; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY appellation
    ADD CONSTRAINT appellation_libelle_key UNIQUE (libelle);


--
-- Name: appellation appellation_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY appellation
    ADD CONSTRAINT appellation_pkey PRIMARY KEY (id);


--
-- Name: contenant contenant_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY contenant
    ADD CONSTRAINT contenant_pkey PRIMARY KEY (id);


--
-- Name: recoltant recoltant_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY recoltant
    ADD CONSTRAINT recoltant_pkey PRIMARY KEY (id);


--
-- Name: region region_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY region
    ADD CONSTRAINT region_pkey PRIMARY KEY (id);


--
-- Name: stock stock_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY stock
    ADD CONSTRAINT stock_pkey PRIMARY KEY (vin_id, contenant_id, annee);


--
-- Name: type_vin type_vin_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY type_vin
    ADD CONSTRAINT type_vin_pkey PRIMARY KEY (id);


--
-- Name: vin vin_pkey; Type: CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY vin
    ADD CONSTRAINT vin_pkey PRIMARY KEY (id);


--
-- Name: appellation appellation_region_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY appellation
    ADD CONSTRAINT appellation_region_id_fkey FOREIGN KEY (region_id) REFERENCES region(id) ON DELETE CASCADE;


--
-- Name: stock stock_contenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY stock
    ADD CONSTRAINT stock_contenant_id_fkey FOREIGN KEY (contenant_id) REFERENCES contenant(id) ON DELETE CASCADE;


--
-- Name: stock stock_vin_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY stock
    ADD CONSTRAINT stock_vin_id_fkey FOREIGN KEY (vin_id) REFERENCES vin(id) ON DELETE CASCADE;


--
-- Name: vin vin_appellation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY vin
    ADD CONSTRAINT vin_appellation_id_fkey FOREIGN KEY (appellation_id) REFERENCES appellation(id) ON DELETE CASCADE;


--
-- Name: vin vin_recoltant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY vin
    ADD CONSTRAINT vin_recoltant_id_fkey FOREIGN KEY (recoltant_id) REFERENCES recoltant(id) ON DELETE CASCADE;


--
-- Name: vin vin_type_vin_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: userdb
--

ALTER TABLE ONLY vin
    ADD CONSTRAINT vin_type_vin_id_fkey FOREIGN KEY (type_vin_id) REFERENCES type_vin(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--