Guest User

Untitled

a guest
Jul 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. -- Suppression des tables existantes
  2. drop table Inscription;
  3. drop table Activite;
  4. drop table Atelier;
  5. drop table Animateur;
  6.  
  7. -- Atelier 1.1
  8. drop table Adherent cascade constraints purge;
  9. create table Adherent (
  10. no_adher number(4) constraint adherent_pk primary key,
  11. nom varchar2(25) constraint adherent_nom_nn not null,
  12. prenom varchar2(25),
  13. rue varchar2(35),
  14. cp char(5),
  15. ville varchar2(25),
  16. date_naissance date,
  17. sexe char(1) check(sexe in ('F','M'))
  18. );
  19.  
  20. create table Animateur (
  21. no_anim number(4)
  22. constraint pk_animateur primary key,
  23. nom varchar2(25)
  24. constraint nn_animateur_nom not null,
  25. prenom varchar2(25),
  26. tel char(14),
  27. cout_heure number(4)
  28. );
  29.  
  30. create table Atelier (
  31. no_atel number(4)
  32. constraint atelier_pk primary key,
  33. intitule varchar2(35)
  34. constraint atelier_intitule_nn not null,
  35. genre varchar2(9)
  36. constraint atelier_genre_ck check(upper(genre) in ('SCIENCES','TNIC','CULTURE','SPORT')),
  37. illustration blob,
  38. vente_heure number(4),
  39. no_anim number(4),
  40. constraint atelier_no_anim_fk foreign key (no_anim)
  41. references Animateur(no_anim) on delete set null
  42. -- on conserve l'atelier si l'animateur est supprimé,
  43. -- l'atelier ne référence plus auncun animateur (no_anim is null)
  44. );
  45.  
  46. create table Activite (
  47. no_atel number(4),
  48. jour char(2),
  49. duree number(2),
  50. constraint activite_pk primary key (no_atel, jour),
  51. constraint activite_atelier_fk
  52. foreign key (no_atel) references Atelier(no_atel)
  53. on delete cascade
  54. -- on supprime toutes les activités si l'atelier est supprimé
  55. );
  56.  
  57. create table Inscription (
  58. no_insc number(4),
  59. no_adher number(4),
  60. no_atel number(4),
  61. jour char(2),
  62. date_inscription date
  63. constraint inscription_date_inscr_nn not null,
  64. note number(2),
  65. constraint inscription_pk primary key (no_insc),
  66. constraint inscription_no_adher_fk
  67. foreign key (no_adher) references Adherent(no_adher)
  68. on delete cascade,
  69. constraint inscription_no_atel_fk
  70. foreign key (no_atel) references Atelier(no_atel)
  71. on delete cascade,
  72. constraint inscription_activite_fk
  73. foreign key (no_atel,jour) references Activite(no_atel,jour)
  74. on delete cascade
  75. );
  76.  
  77. -- Atelier 1.2
  78. alter table Animateur add (
  79. no_resp number(4),
  80. fonction char(10),
  81. constraint animateur_fonction_ck check (fonction in ('Agent','Cadre','Directeur')),
  82. constraint animateur_animateur_fk
  83. foreign key (no_resp) references Animateur(no_anim)
  84. );
  85.  
  86. alter table Inscription add (
  87. date_sortie date,
  88. constraint inscription_date_ck check (date_sortie > date_inscription)
  89. );
  90.  
  91. alter table Atelier drop constraint atelier_genre_ck;
  92. alter table Atelier add constraint atelier_genre_ck
  93. check(genre in ('SCIENCES','NTIC','CULTURE','SPORT','MUSIQUE'));
  94.  
  95. alter table Animateur drop constraint animateur_animateur_fk;
  96. alter table Animateur add constraint animateur_animateur_fk
  97. foreign key (no_resp) references Animateur(no_anim) on delete set null;
Add Comment
Please, Sign In to add comment