Skip to content

Database Setup

Elaeagnifolia edited this page Mar 3, 2023 · 1 revision

The following covers how the database structure for this project is currently setup, as well as a basic snippet to help setup the database. The project currently uses PostgreSQL, but can potentially be ported to other SQL-based databases of choice (untested).

Tables

attendees

Table that keeps track of all meetup attendees.

Column Type Description
id integer Auto-incrementing attendee id
name character varying(100) Name of the attendee
order_id character varying(30) If the list of attendees comes from somewhere like Shopify where RSVPs were purchased, this field will be populated with their order ID.
checked_in boolean Whether or not the attendee has checked in for the meetup
raffle_number integer The raffle number of the attendee
raffle_winner boolean Marks if attendee has won a raffle
meetup_name character varying(100) The name of the meetup this attendee is going to (e.g. Dallas Dec. 2022).
email character varying(100) E-mail of the attendee

raffle_history

Table that keeps track of all raffle rolls, including raffle wins that aren't claimed.

| id | integer | Auto-incrementing raffle history id | | attendee_id | integer | The id of the attendee who won the raffle | | roll_timestamp | timestamp with time zone | The exact timestamp of when a user won the raffle (May be useful if we ever need to know when someone won something) | | claimed | boolean | Whether or not the raffle roll was claimed by the winner |

Creation SQL

CREATE TABLE IF NOT EXISTS public.attendees
(
    id integer NOT NULL DEFAULT nextval('attendees_id_seq'::regclass),
    name character varying(100) COLLATE pg_catalog."default",
    order_id character varying(30) COLLATE pg_catalog."default",
    checked_in boolean DEFAULT false,
    raffle_number integer DEFAULT '-1'::integer,
    raffle_winner boolean DEFAULT false,
    meetup_name character varying(100) COLLATE pg_catalog."default",
    email character varying(100) COLLATE pg_catalog."default",
    CONSTRAINT attendees_pkey PRIMARY KEY (id)
)

CREATE TABLE IF NOT EXISTS public.raffle_history
(
    id integer NOT NULL DEFAULT nextval('raffle_history_id_seq'::regclass),
    attendee_id integer NOT NULL,
    roll_timestamp timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    claimed boolean DEFAULT false,
    CONSTRAINT raffle_history_pkey PRIMARY KEY (id),
    CONSTRAINT raffle_history_attendee_id_fkey FOREIGN KEY (attendee_id)
        REFERENCES public.attendees (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
Clone this wiki locally