Changed database structure
This commit is contained in:
parent
a49f15b9f0
commit
818feac63f
@ -1,36 +1,57 @@
|
||||
-- see database.uxf
|
||||
CREATE TABLE IF NOT EXISTS visitor(
|
||||
visitor_id INTEGER PRIMARY KEY,
|
||||
platform TEXT,
|
||||
browser TEXT,
|
||||
|
||||
ip_range_id INTEGER,
|
||||
platform_id INTEGER,
|
||||
browser_id INTEGER,
|
||||
is_human INTEGER,
|
||||
range_id INTEGER
|
||||
is_mobile INTEGER,
|
||||
FOREIGN KEY(platform_id) REFERENCES platform(platform_id),
|
||||
FOREIGN KEY(browser_id) REFERENCES browser(browser_id),
|
||||
FOREIGN KEY(ip_range_id) REFERENCES ip_range(ip_range_id)
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS platform(
|
||||
platform_id INTEGER PRIMARY KEY,
|
||||
name TEXT UNIQUE
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS browser(
|
||||
browser_id INTEGER PRIMARY KEY,
|
||||
name TEXT UNIQUE
|
||||
) STRICT;
|
||||
|
||||
|
||||
-- REQUEST
|
||||
CREATE TABLE IF NOT EXISTS request(
|
||||
request_id INTEGER PRIMARY KEY,
|
||||
visitor_id INTEGER,
|
||||
route_id INTEGER,
|
||||
referer INTEGER,
|
||||
time INTEGER,
|
||||
status INTEGER,
|
||||
FOREIGN KEY(visitor_id) REFERENCES visitor(visitor_id),
|
||||
group_id INTEGER,
|
||||
FOREIGN KEY(group_id) REFERENCES filegroup(group_id),
|
||||
date INTEGER,
|
||||
referer TEXT,
|
||||
status INTEGER
|
||||
FOREIGN KEY(route_id) REFERENCES route(route_id),
|
||||
FOREIGN KEY(referer) REFERENCES referer(referer_id)
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS filegroup(
|
||||
group_id INTEGER PRIMARY KEY,
|
||||
groupname TEXT
|
||||
) STRICT;
|
||||
CREATE TABLE IF NOT EXISTS file(
|
||||
filename TEXT,
|
||||
group_id INTEGER,
|
||||
FOREIGN KEY(group_id) REFERENCES filegroup(group_id)
|
||||
CREATE TABLE IF NOT EXISTS referer(
|
||||
referer_id INTEGER PRIMARY KEY,
|
||||
name TEXT UNIQUE
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS route(
|
||||
route_id INTEGER PRIMARY KEY,
|
||||
name TEXT UNIQUE
|
||||
) STRICT;
|
||||
|
||||
|
||||
-- GEOIP
|
||||
CREATE TABLE IF NOT EXISTS ip_range(
|
||||
range_id INTEGER PRIMARY KEY,
|
||||
from INTEGER,
|
||||
to INTEGER,
|
||||
ip_range_id INTEGER PRIMARY KEY,
|
||||
low INTEGER UNIQUE,
|
||||
high INTEGER UNIQUE,
|
||||
city_id INTEGER,
|
||||
FOREIGN KEY(city_id) REFERENCES city(city_id)
|
||||
) STRICT;
|
||||
@ -45,6 +66,6 @@ CREATE TABLE IF NOT EXISTS city(
|
||||
|
||||
CREATE TABLE IF NOT EXISTS country(
|
||||
country_id INTEGER PRIMARY KEY,
|
||||
name TEXT,
|
||||
code TEXT
|
||||
name TEXT UNIQUE,
|
||||
code TEXT UNIQUE,
|
||||
) STRICT;
|
||||
|
Loading…
Reference in New Issue
Block a user