Repository navigation
Database
Doug Hagan edited this page Jan 22, 2017
·
11 revisions
- Login to jumpbox.
- Run
aurora/connect.sh. Enter password when prompted (from gdrive). - After login, a mysql client is presented.
> show databases;
> use *<database>*;
> show tables;
> show columns from *<table>*;
> select count(*) from h2conversation
where creation > UNIX_TIMESTAMP('20160801') * 1000;
> select count(distinct author) from h2conversation
where creation > UNIX_TIMESTAMP('20160801') * 1000;
> select count(id) from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000);
> select count(id) from h2multiwordtext where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000);
> select count(id) from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000);
> select count(id) from h2quizresponse where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000);
> select sum(
( select count(id) from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(id) from h2text where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(id) from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) )
);
> select count(id) from h2quizresponse where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000);
> select sum(
( select count(id) from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(id) from h2text where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(id) from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(id) from h2quizresponse where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) )
);
Incorrect - counts the same author multiple times for different stanza types
> select sum(
( select count(distinct author) from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(distinct author) from h2text where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(distinct author) from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) )
);
or:
> select count(a) from (
select distinct author as a from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
union
select distinct author as a from h2text where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
union
select distinct author as a from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
) as bob;
> select count(distinct author) from h2quizresponse where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000);
Incorrect - counts the same author multiple times for different stanza types
> select sum(
( select count(distinct author) from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(distinct author) from h2text where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(distinct author) from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) ) +
( select count(distinct author) from h2quizresponse where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000) )
);
or:
> select count(a) from (
select distinct author as a from h2ink where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
union
select distinct author as a from h2text where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
union
select distinct author as a from h2image where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
union
select distinct author as a from h2quizresponse where timestamp_c > (UNIX_TIMESTAMP('20160801') * 1000)
) as bob;
> select count(distinct author) from h2attendance
where timestamp_c > UNIX_TIMESTAMP('20160801') * 1000;