Self hosted embedded mini-surveys
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. CREATE TABLE user (
  2. id INTEGER PRIMARY KEY,
  3. username TEXT UNIQUE NOT NULL,
  4. password TEXT NOT NULL
  5. );
  6. CREATE TABLE question (
  7. id INTEGER PRIMARY KEY,
  8. user_id INTEGER NOT NULL,
  9. title TEXT NOT NULL,
  10. description TEXT,
  11. type TEXT NOT NULL,
  12. FOREIGN KEY (user_id) REFERENCES user(id),
  13. CHECK (type IN ('freeform', 'numeric', 'single', 'multiple'))
  14. );
  15. CREATE TABLE question_config (
  16. id INTEGER PRIMARY KEY,
  17. question_id INTEGER NOT NULL,
  18. key TEXT NOT NULL,
  19. value TEXT NOT NULL,
  20. FOREIGN KEY (question_id) REFERENCES question(id),
  21. UNIQUE (question_id, key)
  22. );
  23. CREATE TABLE choice (
  24. id INTEGER PRIMARY KEY,
  25. question_id INTEGER NOT NULL,
  26. value TEXT NOT NULL,
  27. FOREIGN KEY (question_id) REFERENCES question(id),
  28. UNIQUE (question_id, value)
  29. );
  30. CREATE TABLE free_form_response (
  31. id INTEGER PRIMARY KEY,
  32. question_id INTEGER NOT NULL,
  33. value TEXT NOT NULL,
  34. FOREIGN KEY (question_id) REFERENCES question(id)
  35. );
  36. CREATE TABLE choice_response (
  37. id INTEGER PRIMARY KEY,
  38. question_id INTEGER NOT NULL,
  39. choice_id INTEGER NOT NULL,
  40. FOREIGN KEY (question_id) REFERENCES question(id),
  41. FOREIGN KEY (choice_id) REFERENCES choice(id)
  42. );