Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. create table historic
  2. (
  3. id serial not null
  4. constraint table_name_pkey
  5. primary key,
  6. film_name varchar,
  7. category varchar,
  8. time_utc timestamp
  9. )
  10. ;
  11.  
  12. create unique index table_name_id_uindex
  13. on historic (id)
  14. ;
  15.  
  16. create table measurements
  17. (
  18. id serial not null
  19. constraint measurements_pkey
  20. primary key,
  21. historic_rowid integer not null
  22. constraint measurements_historic_id_fk
  23. references historic,
  24. measurement double precision
  25. )
  26. ;
  27.  
  28. create unique index measurements_id_uindex
  29. on measurements (id)
  30. ;
  31.  
  32. SELECT h.film_name, h.category, m.measurement, h.time_utc
  33. FROM historic h
  34. LEFT JOIN measurements m on m.historic_rowid == h.id
  35. WHERE h.category = 'sci-fi';
  36.  
  37. film_name, category, measurement, time_utc
  38.  
  39. film_name, category, measurement, time_window
  40. ---------------------------------------------
  41. film_a, sci-fi, 0.234234, 0_to_15
  42. film_b, sci-fi, 0.692859, 15_to_30
  43. film_c, sci-fi, 0.875854, 30_to_45
  44. film_d, sci-fi, 0.583465, 45_to_60
  45. film_e, sci-fi, 0.265334, 60_to_75
  46. film_f, sci-fi, 0.152545, 75_to_90
  47. ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement