Changed database structure

This commit is contained in:
matthias@arch 2023-05-11 13:05:27 +02:00
parent a49f15b9f0
commit 818feac63f

View File

@ -1,36 +1,57 @@
-- see database.uxf
CREATE TABLE IF NOT EXISTS visitor( CREATE TABLE IF NOT EXISTS visitor(
visitor_id INTEGER PRIMARY KEY, visitor_id INTEGER PRIMARY KEY,
platform TEXT,
browser TEXT, ip_range_id INTEGER,
platform_id INTEGER,
browser_id INTEGER,
is_human 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; ) 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( CREATE TABLE IF NOT EXISTS request(
request_id INTEGER PRIMARY KEY, request_id INTEGER PRIMARY KEY,
visitor_id INTEGER, visitor_id INTEGER,
route_id INTEGER,
referer INTEGER,
time INTEGER,
status INTEGER,
FOREIGN KEY(visitor_id) REFERENCES visitor(visitor_id), FOREIGN KEY(visitor_id) REFERENCES visitor(visitor_id),
group_id INTEGER, FOREIGN KEY(route_id) REFERENCES route(route_id),
FOREIGN KEY(group_id) REFERENCES filegroup(group_id), FOREIGN KEY(referer) REFERENCES referer(referer_id)
date INTEGER,
referer TEXT,
status INTEGER
) STRICT; ) STRICT;
CREATE TABLE IF NOT EXISTS filegroup( CREATE TABLE IF NOT EXISTS referer(
group_id INTEGER PRIMARY KEY, referer_id INTEGER PRIMARY KEY,
groupname TEXT name TEXT UNIQUE
) STRICT;
CREATE TABLE IF NOT EXISTS file(
filename TEXT,
group_id INTEGER,
FOREIGN KEY(group_id) REFERENCES filegroup(group_id)
) STRICT; ) STRICT;
CREATE TABLE IF NOT EXISTS route(
route_id INTEGER PRIMARY KEY,
name TEXT UNIQUE
) STRICT;
-- GEOIP
CREATE TABLE IF NOT EXISTS ip_range( CREATE TABLE IF NOT EXISTS ip_range(
range_id INTEGER PRIMARY KEY, ip_range_id INTEGER PRIMARY KEY,
from INTEGER, low INTEGER UNIQUE,
to INTEGER, high INTEGER UNIQUE,
city_id INTEGER, city_id INTEGER,
FOREIGN KEY(city_id) REFERENCES city(city_id) FOREIGN KEY(city_id) REFERENCES city(city_id)
) STRICT; ) STRICT;
@ -45,6 +66,6 @@ CREATE TABLE IF NOT EXISTS city(
CREATE TABLE IF NOT EXISTS country( CREATE TABLE IF NOT EXISTS country(
country_id INTEGER PRIMARY KEY, country_id INTEGER PRIMARY KEY,
name TEXT, name TEXT UNIQUE,
code TEXT code TEXT UNIQUE,
) STRICT; ) STRICT;