forked from codyjarvis/HarvTrack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
26 lines (23 loc) · 997 Bytes
/
schema.sql
File metadata and controls
26 lines (23 loc) · 997 Bytes
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
drop table if exists users;
create table users (
id integer primary key,
username text not null
);
drop table if exists activityType;
create table activityType (
id integer primary key,
activityType text not null
);
drop table if exists activity;
create table activity (
id integer primary key,
inputUser integer not null,
activityType integer not null,
activityDescription text,
activityLengthSec integer,
entryDatetime numeric
,FOREIGN KEY(inputUser) REFERENCES users(id)
,FOREIGN KEY(activityType) REFERENCES activityType(id)
);
drop view if exists activity_view;
create view activity_view as select b.username as Observer, c.activityType as Activity, a.ActivityDescription as Notes, strftime('%m/%d/%Y',datetime(a.entryDatetime, 'unixepoch', 'localtime')) as Date, strftime('%H:%M',datetime(a.entryDatetime, 'unixepoch', 'localtime')) as Time, a.ActivityLengthSec as LengthInSec from activity as a join users as b on b.id = a.inputUser join activityType c on a.activityType = c.id;