Created
August 28, 2018 10:52
-
-
Save shahidhk/7fa861ceb499024a2224ce1158c5e9ca to your computer and use it in GitHub Desktop.
Schema for a realtime poll application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE "user" ( | |
| id uuid DEFAULT gen_random_uuid() NOT NULL, | |
| created_at timestamp with time zone DEFAULT now() NOT NULL, | |
| online_ping boolean, | |
| last_seen_at timestamp with time zone | |
| ); | |
| CREATE TABLE poll ( | |
| id uuid DEFAULT gen_random_uuid() NOT NULL, | |
| created_at timestamp with time zone DEFAULT now() NOT NULL, | |
| question text NOT NULL | |
| ); | |
| CREATE TABLE option ( | |
| id uuid DEFAULT gen_random_uuid() NOT NULL, | |
| poll_id uuid NOT NULL REFERENCES poll (id), | |
| text text NOT NULL | |
| ); | |
| CREATE TABLE vote ( | |
| id uuid DEFAULT gen_random_uuid() NOT NULL, | |
| created_by_user_id uuid NOT NULL REFERENCES "user" (id), | |
| option_id uuid NOT NULL REFERENCES option (id), | |
| created_at timestamp with time zone DEFAULT now() NOT NULL | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment