Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions internal/db/sql/queries/board.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
-- name: GetBoard :one
SELECT
id,
name,
branch,
github,
discord,
year,
bio
full_name,
picture,
discord
FROM
board_member
officers
WHERE
id = ?;
uuid = ?;

-- name: GetPositions :one
SELECT
tiers.title,
tiers.team,
positions.semester
FROM
officers
INNER JOIN positions
ON officers.uuid = positions.oid
INNER JOIN tiers
ON positions.tier = tiers.tier
WHERE officers.full_name = ?
34 changes: 18 additions & 16 deletions internal/db/sql/schemas/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,29 @@ CREATE TABLE IF NOT EXISTS announcement (
--UNIQUE (id)
);

CREATE TABLE IF NOT EXISTS board_member (
id CHAR(4) PRIMARY KEY,
name VARCHAR(30) NOT NULL,
branch VARCHAR(20) NOT NULL,
github VARCHAR(39),
discord VARCHAR(32),
year INT,
bio TEXT
CREATE TABLE IF NOT EXISTS officers (
uuid CHAR(4) PRIMARY KEY,
full_name VARCHAR(30) NOT NULL,
picture VARCHAR(37),
github VARCHAR(64),
discord VARCHAR(32)
);

CREATE TABLE IF NOT EXISTS branch (
name VARCHAR(20) PRIMARY KEY
CREATE TABLE IF NOT EXISTS tiers (
tier INT PRIMARY KEY,
title VARCHAR(40),
t_index INT,
team VARCHAR(20)
);

CREATE TABLE IF NOT EXISTS member_of (
bmid CHAR(4) NOT NULL,
bname VARCHAR(20) NOT NULL,
PRIMARY KEY (bmid, bname),
CREATE TABLE IF NOT EXISTS positions (
oid CHAR(4) NOT NULL,
semester CHAR(3) NOT NULL,
tier INT NOT NULL,
PRIMARY KEY (oid, semester, tier),

CONSTRAINT fk_board FOREIGN KEY (bmid) REFERENCES board_member (id),
CONSTRAINT fk_branch FOREIGN KEY (bname) REFERENCES branch (name)
CONSTRAINT fk_officers FOREIGN KEY (oid) REFERENCES officer (uuid),
CONSTRAINT fk_tiers FOREIGN KEY (tier) REFERENCES branch (tier)
);

-- TODO: Create a table for access tokens for the API.
Loading