TT22

Projet BDD - Final

Mar 20th, 2016
941
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table Client (
  2.     IdClient int not null,
  3.     Nom TEXT not null,
  4.     Prenom TEXT not null,
  5.     Sexe BOOLEAN not null,
  6.     DDN DATE not null,
  7.     Pcode int not null
  8.         CHECK (Pcode > 0),
  9.     Score int not null
  10.         CHECK (Score > 0 AND Score <= 10),
  11.     primary key (IdClient)
  12. );
  13.  
  14. create table Sport (
  15.     IdSport int not null,
  16.     Nom TEXT not null,
  17.     NbMin int not null
  18.         CHECK (NbMin >= 0),
  19.     NbMax int not null
  20.         CHECK (NbMax >= NbMin),
  21.     primary key (IdSport)
  22. );
  23.  
  24. create table Lieu (
  25.     IdLieu int not null,
  26.     Intitule TEXT not null,
  27.     PCode int not null
  28.         CHECK (Pcode > 0),
  29.     Capacite int not null
  30.         CHECK (Capacite > 0),
  31.     IdSport int not null UNIQUE,
  32.     primary key (IdLieu),
  33.     constraint se_pratique
  34.         foreign key (IdSport)
  35.             references Sport (IdSport)
  36. );
  37.  
  38. create table Event (
  39.     IdEv int not null,
  40.     Niveau int not null
  41.         CHECK (Niveau > 0),
  42.     Date DATE not null,
  43.     IdClient int not null UNIQUE,
  44.     IdLieu int not null UNIQUE,
  45.     primary key (IdEv),
  46.     constraint organise
  47.         foreign key (IdClient)
  48.             references Client (IdClient),
  49.     constraint se_situe
  50.         foreign key (IdLieu)
  51.             references Lieu (IdLieu)
  52. );
  53.  
  54. create table Terrain (
  55.     Surface int not null
  56.         CHECK (Surface > 0),
  57.     Type TEXT not null,
  58.     IdTer int not null,
  59.     IdLieu int not null UNIQUE,
  60.     primary key (IdTer),
  61.     constraint est_compose
  62.         foreign key (IdLieu)
  63.             references Lieu (IdLieu)
  64. );
  65.  
  66. create table participe (
  67.     IdClient int not null,
  68.     IdEv int not null UNIQUE,
  69.     primary key (IdClient),
  70.     foreign key (IdClient)
  71.         references Client (IdClient),
  72.     foreign key (IdEv)
  73.         references Event (IdEv)
  74. );
Advertisement