-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake tables.sql
More file actions
156 lines (126 loc) · 4.81 KB
/
make tables.sql
File metadata and controls
156 lines (126 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
create table if not exists alliances(
ID integer primary key,
ccpID integer not null unique,
name varchar(35) not null
);
create table if not exists corporations(
ID integer primary key,
ccpID integer not null unique,
name varchar(35) not null,
alliance integer,
foreign key(alliance) references alliances(id)
);
create table if not exists players (
ID integer primary key,
ccpID integer not null unique,
name varchar(35) not null,
corporation integer not null,
foreign key(corporation) references corporations(id)
);
create table if not exists systems(
id integer primary key,
ccpID integer not null unique,
name varchar(35) not null,
lastPulled datetime
);
create table if not exists ships(
id integer primary key,
ccpID integer not null unique,
name varchar(35) not null
);
create table if not exists Structures(
id integer primary key,
ccpID integer not null unique,
name varchar(35),
corporation integer,
player integer,
foreign key(corporation) references corporations(id),
foreign key (player) references players(id)
);
create table if not exists items(
id integer primary key,
ccpID integer not null unique,
name varchar(100)
);
create table if not exists kills (
id integer primary key,
zKillID integer not null unique,
victim integer,
ship integer,
[structure] integer,
timeOfDeath datetime not null,
system integer not null,
corporation integer not null,
alliance integer,
isk integer,
foreign key (alliance) references alliances(ccpid),
foreign key (corporation) references corporation(ccpID),
foreign key (system) references systems(ccpID),
foreign key(victim) references players(ccpID)
--foreign key(ship) references ships(id),
--foreign key(structure) references Structures(id)
);
create table if not exists attackers (
id integer primary key,
player integer,
[structure] integer,
kill integer not null,
damage integer,
corporation integer,
alliance integer,
ship integer,
foreign key (alliance) references alliances(ccpid),
foreign key(corporation) references corporations(ccpID),
foreign key(player) references players(ccpID),
foreign key(structure) references structures(ccpID),
foreign key(kill) references kills(zKillID)
);
create table if not exists fitting(
id integer primary key,
kill integer not null,
foreign key (kill) references kills(id)
);
create table if not exists killsRaw(
id integer primary key,
zKillID integer not null unique,
killmail varchar(MAX) not null, --sqlite ignores len and lets you store as much as you want
processed boolean not null default false,
skipped boolean not null default false
);
create table if not exists reportCache(
id integer primary key,
reportType int not null,
entityID int not null,
cacheTime datetime not null,
content varchar not null,
valid boolean not null
);
create index if not exists attackersCorporation on attackers (corporation);
create index if not exists attackerszKill on attackers (kill);
create index if not exists attackersPlayer on attackers (player);
create index if not exists attackersAlliance on attackers (alliance);
create index if not exists attackersKillPlayer on attackers (player, kill);
create index if not exists attackersKillCorporation on attackers (corporation, kill);
create index if not exists attackersKillAlliance on attackers (alliance, kill);
create index if not exists killsCorporation on kills (corporation);
create unique index if not exists killszKill on kills (zKillID);
create index if not exists killsSystem on kills (system);
create index if not exists killsAlliance on kills (alliance);
create index if not exists killsVictim on kills (victim);
create index if not exists killsZkillVictim on kills (zKillID, victim);
create index if not exists killsZkillAlliance on kills (zkillid, alliance);
create index if not exists killsZkillCorporation on kills (zkillid, corporation);
create unique index if not exists playersCCPID on players (ccpid);
create unique index if not exists corporationsCCPID on corporations (ccpid);
create unique index if not exists alliancesCCPID on alliances (ccpid);
create index if not exists playersName on players (name);
create index if not exists corporationsName on corporations (name);
create index if not exists alliancesName on alliances (name);
create index if not exists killsrawZkill on killsraw (zkillid);
create index if not exists killsrawProcessed on killsraw (processed);
create index if not exists killsrawSkipped on killsraw (skipped);
create index if not exists killsSystemCorporation on kills(system, corporation);
create index if not exists killsSystemAlliance on kills(system, alliance);
create index if not exists attackersSystemCorporation on attackers (kill, corporation);
create index if not exists attackersSystemAlliance on attackers (kill, alliance);
create index if not exists reportCacheAll on reportCache (reportType, entityID, cacheTime, valid);