diff --git a/ddl.sql b/ddl.sql index a6010b6..74962a8 100644 --- a/ddl.sql +++ b/ddl.sql @@ -2,16 +2,26 @@ create table guild ( id integer primary key, name text ); +create unique index idx_guild_name on guild(name); -create table stinky ( +create table player ( id integer primary key, name text, guild integer references guild(id) ); +create unique index idx_player_name on player(name); + +create table association ( + id integer primary key, + lhs integer references player(id), + rhs integer references player(id), + note text +); create table note ( id integer primary key, content text, timestamp string, - stinky integer references stinky(id) -); \ No newline at end of file + player integer references player(id) +); +create unique index idx_note_content on note(timestamp, player); \ No newline at end of file diff --git a/types.go b/types.go index d6d642e..0fa21c6 100644 --- a/types.go +++ b/types.go @@ -5,28 +5,35 @@ import "time" type ( Guild struct { ID int - Name string + Name string `json:"name"` } - - Stinky struct { - ID int - Name string - Guild Guild + Player struct { + ID int + Name string `json:"name"` + Guild Guild `json:"guild"` + } + Association struct { + ID int + LHS Player + RHS Player + Note string } - Note struct { ID int Content string Timestamp time.Time - Stinky Stinky + Player Player } ) type NoteData struct { - Player string - PlayerID int - Date time.Time - Guild string - GuildID int - Note string + Player string + Date time.Time + Guild string + Note string + Associations []NoteAssociationData } +type NoteAssociationData struct { + Player string + Note string +} \ No newline at end of file