2020-07-17 10:03:38 +02:00
|
|
|
create table website (
|
2020-07-19 08:54:25 +02:00
|
|
|
website_id serial primary key,
|
|
|
|
website_uuid uuid unique not null,
|
|
|
|
hostname varchar(100) not null,
|
2020-07-17 10:03:38 +02:00
|
|
|
created_at timestamp with time zone default current_timestamp
|
|
|
|
);
|
|
|
|
|
|
|
|
create table session (
|
2020-07-19 08:54:25 +02:00
|
|
|
session_id serial primary key,
|
|
|
|
session_uuid uuid unique not null,
|
|
|
|
website_id int not null references website(website_id) on delete cascade,
|
2020-07-17 10:03:38 +02:00
|
|
|
created_at timestamp with time zone default current_timestamp,
|
2020-07-18 19:36:46 +02:00
|
|
|
hostname varchar(100),
|
2020-07-17 10:03:38 +02:00
|
|
|
browser varchar(20),
|
|
|
|
os varchar(20),
|
|
|
|
screen varchar(11),
|
|
|
|
language varchar(35),
|
|
|
|
country char(2)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table pageview (
|
|
|
|
view_id serial primary key,
|
2020-07-19 08:54:25 +02:00
|
|
|
website_id int not null references website(website_id),
|
|
|
|
session_id int not null references session(session_id) on delete cascade,
|
2020-07-17 10:03:38 +02:00
|
|
|
created_at timestamp with time zone default current_timestamp,
|
|
|
|
url varchar(500) not null,
|
|
|
|
referrer varchar(500)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table event (
|
|
|
|
event_id serial primary key,
|
2020-07-19 08:54:25 +02:00
|
|
|
website_id int not null references website(website_id),
|
|
|
|
session_id int not null references session(session_id) on delete cascade,
|
2020-07-17 10:03:38 +02:00
|
|
|
created_at timestamp with time zone default current_timestamp,
|
|
|
|
url varchar(500) not null,
|
|
|
|
event_type varchar(50) not null,
|
2020-07-19 11:23:15 +02:00
|
|
|
event_value varchar(50) not null
|
2020-07-18 04:33:40 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
create index on session(created_at);
|
2020-07-21 04:24:33 +02:00
|
|
|
create index on session(website_id);
|
|
|
|
|
2020-07-18 04:33:40 +02:00
|
|
|
create index on pageview(created_at);
|
2020-07-21 04:24:33 +02:00
|
|
|
create index on pageview(website_id);
|
|
|
|
create index on pageview(session_id);
|
|
|
|
|
|
|
|
create index on event(created_at);
|
|
|
|
create index on event(website_id);
|
|
|
|
create index on event(session_id);
|