2016-12-10 13:16:05 +00:00
|
|
|
|
|
|
|
CREATE TABLE visitors(
|
2016-12-11 09:58:58 +00:00
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
2016-12-10 13:16:05 +00:00
|
|
|
`visitor_key` VARCHAR(255) NOT NULL,
|
|
|
|
`ip_address` VARCHAR(100) NOT NULL,
|
|
|
|
`device_os` VARCHAR(31) NULL,
|
2016-12-08 21:20:40 +00:00
|
|
|
`browser_name` VARCHAR(31) NULL,
|
|
|
|
`browser_version` VARCHAR(31) NULL,
|
|
|
|
`browser_language` VARCHAR(31) NULL,
|
|
|
|
`screen_resolution` VARCHAR(9) NULL,
|
2016-12-10 13:16:05 +00:00
|
|
|
`country` CHAR(3) NULL
|
2016-12-08 21:20:40 +00:00
|
|
|
);
|
2016-12-10 15:07:03 +00:00
|
|
|
ALTER TABLE visitors ADD UNIQUE(`visitor_key`);
|
|
|
|
|
2016-12-23 14:02:49 +00:00
|
|
|
CREATE TABLE pages(
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`hostname` VARCHAR(63) NOT NULL,
|
|
|
|
`path` VARCHAR(255) NOT NULL,
|
|
|
|
`title` VARCHAR(255) NULL
|
|
|
|
);
|
|
|
|
|
2016-12-10 17:19:44 +00:00
|
|
|
CREATE TABLE pageviews(
|
2016-12-11 09:58:58 +00:00
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
2016-12-10 17:19:44 +00:00
|
|
|
`page_id` INTEGER UNSIGNED NOT NULL,
|
|
|
|
`visitor_id` INTEGER UNSIGNED NOT NULL,
|
|
|
|
`referrer_keyword` TEXT NULL,
|
|
|
|
`referrer_url` TEXT NULL,
|
|
|
|
`timestamp` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
|
|
);
|
|
|
|
ALTER TABLE pageviews ADD FOREIGN KEY(`visitor_id`) REFERENCES visitors(`id`);
|
2016-12-11 09:58:58 +00:00
|
|
|
ALTER TABLE pageviews ADD FOREIGN KEY(`page_id`) REFERENCES pages(`id`);
|
|
|
|
|
2016-12-08 21:20:40 +00:00
|
|
|
CREATE TABLE users (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`email` VARCHAR(255) NOT NULL,
|
|
|
|
`password` VARCHAR(255) NOT NULL
|
|
|
|
);
|
2016-12-11 09:58:58 +00:00
|
|
|
|
2016-12-24 13:12:17 +00:00
|
|
|
CREATE TABLE options (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`name` VARCHAR(255) NOT NULL,
|
|
|
|
`value` VARCHAR(255) DEFAULT ''
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX options_name ON options(`name`);
|
|
|
|
|
2016-12-24 11:07:33 +00:00
|
|
|
CREATE TABLE `total_pageviews` (
|
2016-12-11 09:58:58 +00:00
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
2016-12-24 11:07:33 +00:00
|
|
|
`page_id` INTEGER UNSIGNED NOT NULL,
|
|
|
|
`count` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`count_unique` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`date` DATE NOT NULL
|
|
|
|
);
|
2016-12-25 16:24:53 +00:00
|
|
|
CREATE INDEX total_pageviews_date ON total_pageviews(`date`);
|
|
|
|
ALTER TABLE total_pageviews ADD UNIQUE(`page_id`, `date`);
|
2016-12-24 11:07:33 +00:00
|
|
|
|
|
|
|
CREATE TABLE `total_visitors` (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`count` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`date` DATE NOT NULL
|
|
|
|
);
|
2016-12-25 16:24:53 +00:00
|
|
|
CREATE INDEX total_visitors_date ON total_visitors(`date`);
|
|
|
|
ALTER TABLE total_visitors ADD UNIQUE(`date`);
|
2016-12-24 11:07:33 +00:00
|
|
|
|
|
|
|
CREATE TABLE `total_screens` (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`value` VARCHAR(12) NOT NULL,
|
|
|
|
`count` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`count_unique` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`date` DATE NOT NULL
|
|
|
|
);
|
2016-12-25 16:24:53 +00:00
|
|
|
CREATE INDEX total_screens_date ON total_screens(`date`);
|
|
|
|
ALTER TABLE total_screens ADD UNIQUE(`value`, `date`);
|
2016-12-24 11:07:33 +00:00
|
|
|
|
|
|
|
CREATE TABLE `total_browser_names` (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`value` VARCHAR(50) NOT NULL,
|
|
|
|
`count` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`count_unique` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`date` DATE NOT NULL
|
|
|
|
);
|
2016-12-25 16:24:53 +00:00
|
|
|
CREATE INDEX total_browser_names_date ON total_browser_names(`date`);
|
|
|
|
ALTER TABLE total_browser_names ADD UNIQUE(`value`, `date`);
|
2016-12-24 11:07:33 +00:00
|
|
|
|
|
|
|
CREATE TABLE `total_browser_languages` (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
|
|
|
`value` VARCHAR(12) NOT NULL,
|
|
|
|
`count` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`count_unique` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`date` DATE NOT NULL
|
|
|
|
);
|
2016-12-25 16:24:53 +00:00
|
|
|
CREATE INDEX total_browser_languages_date ON total_browser_languages(`date`);
|
|
|
|
ALTER TABLE total_browser_languages ADD UNIQUE(`value`, `date`);
|
2016-12-24 11:07:33 +00:00
|
|
|
|
|
|
|
CREATE TABLE `total_referrers` (
|
|
|
|
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
2016-12-25 16:24:53 +00:00
|
|
|
`value` VARCHAR(510) NOT NULL,
|
2016-12-24 11:07:33 +00:00
|
|
|
`count` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
`count_unique` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
2016-12-11 09:58:58 +00:00
|
|
|
`date` DATE NOT NULL
|
|
|
|
);
|
2016-12-24 11:07:33 +00:00
|
|
|
CREATE INDEX total_referrers_date ON total_referrers(`date`);
|
2016-12-25 16:24:53 +00:00
|
|
|
ALTER TABLE total_referrers ADD UNIQUE(`value`, `date`);
|