First commit
This commit is contained in:
31
db/createdb.sql
Normal file
31
db/createdb.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
create table exercise (
|
||||
id smallserial primary key,
|
||||
name varchar not null
|
||||
);
|
||||
create table shorthand (
|
||||
exercise smallint not null,
|
||||
name varchar unique not null,
|
||||
constraint fk_exercise foreign key (exercise) references exercise(id)
|
||||
);
|
||||
create table account (
|
||||
id serial primary key,
|
||||
name varchar not null,
|
||||
login varchar not null,
|
||||
birthdate date not null
|
||||
);
|
||||
create table training (
|
||||
id serial primary key,
|
||||
account integer not null,
|
||||
time timestamptz not null default timezone('utc', now()),
|
||||
exercise smallint not null,
|
||||
runs smallint not null,
|
||||
reps smallint not null,
|
||||
kilos numeric(4,1) not null,
|
||||
constraint fk_exercise foreign key (exercise) references exercise(id),
|
||||
constraint fk_account foreign key (account) references account(id)
|
||||
);
|
||||
create view dailylift as select
|
||||
date_trunc('day', time) as time, account, exercise, sum(runs * reps * kilos) as lift
|
||||
from training group by 1, 2, 3;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user