SQL 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # --- Rev:1,Ups - 296accc
  2. create table antworten (
  3. id uuid not null,
  4. text varchar(255) not null,
  5. position integer,
  6. frage_id uuid,
  7. constraint pk_antworten primary key (id)
  8. );
  9. create table fragen (
  10. id uuid not null,
  11. text varchar(255) not null,
  12. position integer,
  13. kategorie_id uuid,
  14. fragetyp_id uuid,
  15. constraint pk_fragen primary key (id)
  16. );
  17. create table fragebogen (
  18. id uuid not null,
  19. name varchar(255) not null,
  20. constraint pk_fragebogen primary key (id)
  21. );
  22. create table fragetypen (
  23. id uuid not null,
  24. name varchar(255) not null,
  25. constraint pk_fragetypen primary key (id)
  26. );
  27. create table kategorien (
  28. id uuid not null,
  29. name varchar(255) not null,
  30. position integer,
  31. fragebogen_id uuid,
  32. constraint pk_kategorien primary key (id)
  33. );
  34. create table profils (
  35. id uuid not null,
  36. nachname varchar(255) not null,
  37. vorname varchar(255) not null,
  38. adresse varchar(255) not null,
  39. constraint pk_profils primary key (id)
  40. );
  41. create table profilfrageantwort (
  42. id uuid not null,
  43. profil_id uuid,
  44. frage_id uuid,
  45. antwort_id uuid,
  46. constraint pk_profilfrageantwort primary key (id)
  47. );
  48. alter table antworten add constraint fk_antworten_frage_id foreign key (frage_id) references fragen (id) on delete restrict on update restrict;
  49. create index ix_antworten_frage_id on antworten (frage_id);
  50. alter table fragen add constraint fk_fragen_kategorie_id foreign key (kategorie_id) references kategorien (id) on delete restrict on update restrict;
  51. create index ix_fragen_kategorie_id on fragen (kategorie_id);
  52. alter table fragen add constraint fk_fragen_fragetyp_id foreign key (fragetyp_id) references fragetypen (id) on delete restrict on update restrict;
  53. create index ix_fragen_fragetyp_id on fragen (fragetyp_id);
  54. alter table kategorien add constraint fk_kategorien_fragebogen_id foreign key (fragebogen_id) references fragebogen (id) on delete restrict on update restrict;
  55. create index ix_kategorien_fragebogen_id on kategorien (fragebogen_id);
  56. alter table profilfrageantwort add constraint fk_profilfrageantwort_profil_id foreign key (profil_id) references profils (id) on delete restrict on update restrict;
  57. create index ix_profilfrageantwort_profil_id on profilfrageantwort (profil_id);
  58. alter table profilfrageantwort add constraint fk_profilfrageantwort_frage_id foreign key (frage_id) references fragen (id) on delete restrict on update restrict;
  59. create index ix_profilfrageantwort_frage_id on profilfrageantwort (frage_id);
  60. alter table profilfrageantwort add constraint fk_profilfrageantwort_antwort_id foreign key (antwort_id) references antworten (id) on delete restrict on update restrict;
  61. create index ix_profilfrageantwort_antwort_id on profilfrageantwort (antwort_id);