Skip to content

DB Schema #19

Description

@AdaephonBen
-- *************** SqlDBM: PostgreSQL ****************;
-- ***************************************************;


-- ************************************** "public"."Team"

CREATE TABLE "public"."Team"
(
 "team_id"              int generated by default as identity NOT NULL,
 "name"                 text NOT NULL,
 "questions_accessible" smallint[] NOT NULL,
 "max_level"            smallint NOT NULL,
 CONSTRAINT "PK_Teams" PRIMARY KEY ( "team_id" ),
 CONSTRAINT "Teams_Name_Unique" UNIQUE ( "name" )
);








-- ************************************** "public"."Statistics"

CREATE TABLE "public"."Statistics"
(

);








-- ************************************** "public"."Question"

CREATE TABLE "public"."Question"
(
 "question_id"     smallint generated by default as identity NOT NULL,
 "question_number" smallint NOT NULL,
 "question"        jsonb NOT NULL,
 "question_type"   smallint NOT NULL,
 "answer"          char(60) NOT NULL,
 CONSTRAINT "PK_Level" PRIMARY KEY ( "question_id" )
);








-- ************************************** "public"."User"

CREATE TABLE "public"."User"
(
 "user_id"       int generated by default as identity NOT NULL,
 "email_id"      varchar(255) NOT NULL,
 "username"      varchar(31) NOT NULL,
 "team_id"       int generated by default as identity NOT NULL,
 "last_modified" timestamp with time zone NOT NULL,
 CONSTRAINT "PK_User" PRIMARY KEY ( "user_id" ),
 CONSTRAINT "User_EmailID_Unique" UNIQUE ( "email_id" ),
 CONSTRAINT "User_Username_Unique" UNIQUE ( "username" ),
 CONSTRAINT "FK_18" FOREIGN KEY ( "team_id" ) REFERENCES "public"."Team" ( "team_id" )
);

CREATE INDEX "fkIdx_18" ON "public"."User"
(
 "team_id"
);








-- ************************************** "public"."Hint"

CREATE TABLE "public"."Hint"
(
 "hint_id"      smallint generated by default as identity NOT NULL,
 "hint_number"  smallint NOT NULL,
 "release_time" timestamp with time zone NOT NULL,
 "question_id"  smallint generated by default as identity NOT NULL,
 "hint"         text NOT NULL,
 CONSTRAINT "PK_Hints" PRIMARY KEY ( "hint_id" ),
 CONSTRAINT "FK_37" FOREIGN KEY ( "question_id" ) REFERENCES "public"."Question" ( "question_id" )
);

CREATE INDEX "fkIdx_37" ON "public"."Hint"
(
 "question_id"
);

Proposed DB Schema.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions