Skip to content

Commit 7d5d981

Browse files
author
Simon Funke
committed
Use country_code instead of source in the multilevel databases
1 parent 83710c3 commit 7d5d981

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

create_multilevel_db.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ CREATE TABLE IF NOT EXISTS `glasnost_daily` (
55
`counter` int NOT NULL,
66
`rangedate` datetime NOT NULL,
77
`destination` varchar(128) NOT NULL,
8-
`source` varchar(128) NOT NULL,
9-
PRIMARY KEY (rangedate, destination, source)
8+
`country_code` varchar(128) NOT NULL,
9+
PRIMARY KEY (rangedate, destination, country_code)
1010
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
1111

12-
INSERT INTO glasnost_daily SELECT COUNT(*) as counter, DATE(date) as rangedate, destination, source FROM glasnost GROUP BY destination, source, DATE(rangedate);
12+
INSERT INTO glasnost_daily SELECT COUNT(*) as counter, DATE(date) as rangedate, destination, country_code FROM glasnost GROUP BY destination, country_code, DATE(rangedate);
1313

1414
/* glasnost_monthly */
1515
DROP TABLE IF EXISTS `glasnost_monthly`;
@@ -18,11 +18,11 @@ CREATE TABLE IF NOT EXISTS `glasnost_monthly` (
1818
`counter` int NOT NULL,
1919
`rangedate` datetime NOT NULL,
2020
`destination` varchar(128) NOT NULL,
21-
`source` varchar(128) NOT NULL,
22-
PRIMARY KEY (rangedate, destination, source)
21+
`country_code` varchar(128) NOT NULL,
22+
PRIMARY KEY (rangedate, destination, country_code)
2323
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
2424

25-
INSERT INTO glasnost_monthly SELECT COUNT(*) as counter, LAST_DAY(date) as rangedate, destination, source FROM glasnost GROUP BY destination, source, LAST_DAY(rangedate);
25+
INSERT INTO glasnost_monthly SELECT COUNT(*) as counter, LAST_DAY(date) as rangedate, destination, country_code FROM glasnost GROUP BY destination, country_code, LAST_DAY(rangedate);
2626

2727
/* glasnost_yearly */
2828
DROP TABLE IF EXISTS `glasnost_yearly`;
@@ -31,8 +31,8 @@ CREATE TABLE IF NOT EXISTS `glasnost_yearly` (
3131
`counter` int NOT NULL,
3232
`rangedate` datetime NOT NULL,
3333
`destination` varchar(128) NOT NULL,
34-
`source` varchar(128) NOT NULL,
35-
PRIMARY KEY (rangedate, destination, source)
34+
`country_code` varchar(128) NOT NULL,
35+
PRIMARY KEY (rangedate, destination, country_code)
3636
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
3737

38-
INSERT INTO glasnost_yearly SELECT COUNT(*) as counter, MAKEDATE(YEAR(date), 1) as rangedate, destination, source FROM glasnost GROUP BY destination, source, MAKEDATE(YEAR(rangedate), 1);
38+
INSERT INTO glasnost_yearly SELECT COUNT(*) as counter, MAKEDATE(YEAR(date), 1) as rangedate, destination, country_code FROM glasnost GROUP BY destination, country_code, MAKEDATE(YEAR(rangedate), 1);

0 commit comments

Comments
 (0)