create table msmpoint (
    skunitid      TEXT        PRIMARY KEY
  , msmid         TEXT        NOT NULL    UNIQUE
  , mac           TEXT        NOT NULL    UNIQUE
  , name          TEXT
  , hardware      TEXT
);

create table youtube (
    unit_id                       INTEGER       NOT NULL
  , dtime                         TEXT          NOT NULL
  , codec                         TEXT
  , download_duration             INTEGER
  , prebuffering_duration         INTEGER
  , bytes_sec                     INTEGER
  , successes                     INTEGER
  , failures                      INTEGER
  , location_id                   INTEGER
  , startup_delay                 INTEGER
  , range                         INTEGER
  , error_code                    INTEGER
  , error_msg                     TEXT

  , stall_events                  INTEGER
  , stall_duration_avg            INTEGER
  , stall_duration_total          INTEGER

  , video_id                      TEXT
  , video_duration                INTEGER
  , video_itag                    INTEGER
  , video_download_bytes_sec      INTEGER
  , video_download_bytes          INTEGER
  , video_download_duration       INTEGER
  , video_hostname                TEXT
  , video_address                 TEXT
  , video_connect_time            INTEGER
  , video_bitrate                 INTEGER

  , audio_itag                    INTEGER
  , audio_download_bytes_sec      INTEGER
  , audio_download_bytes          INTEGER
  , audio_download_duration       INTEGER
  , audio_hostname                TEXT
  , audio_address                 TEXT
  , audio_connect_time            INTEGER
  , audio_bitrate                 INTEGER

  , web_connect_time              INTEGER
  , max_bitrate                   INTEGER

  , FOREIGN KEY ( unit_id ) REFERENCES msmpoint ( skunitid ) ON DELETE CASCADE
);
