
SET transaction_timeout = 0;
SELECT pg_catalog.set_config('search_path', '', false);



--
-- Name: order_cart; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.order_cart (
    user_id bigint NOT NULL,
    discount_id integer,
    status_id integer NOT NULL,
    order_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    total_price numeric(12,2) NOT NULL,
    CONSTRAINT chk_order_total CHECK ((total_price >= (0)::numeric))
);


--
-- Name: Order_order_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."Order_order_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: Order_order_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."Order_order_id_seq" OWNED BY public.order_cart.order_id;


--
-- Name: user_app; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_app (
    user_id bigint NOT NULL,
    username character varying(20) NOT NULL,
    email character varying(50) NOT NULL,
    contact_phone character varying(50),
    CONSTRAINT chk_email_format CHECK (((email)::text ~~ '%@%.%'::text))
);


--
-- Name: User_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."User_user_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: User_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."User_user_id_seq" OWNED BY public.user_app.user_id;


--
-- Name: attribute; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.attribute (
    name text NOT NULL,
    attribute_id integer NOT NULL,
    data_type character varying(20) NOT NULL,
    description text,
    is_required boolean NOT NULL
);


--
-- Name: attribute_attribute_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.attribute_attribute_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: attribute_attribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.attribute_attribute_id_seq OWNED BY public.attribute.attribute_id;


--
-- Name: category; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.category (
    id integer NOT NULL,
    name character varying(100) NOT NULL
);


--
-- Name: category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.category_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.category_id_seq OWNED BY public.category.id;


--
-- Name: discount; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.discount (
    event_id integer NOT NULL,
    discount_id integer NOT NULL,
    discount_percent numeric(5,2) NOT NULL,
    promo_code_id integer,
    CONSTRAINT chk_discount_percent CHECK (((discount_percent >= (0)::numeric) AND (discount_percent <= (100)::numeric)))
);


--
-- Name: discount_discount_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.discount_discount_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: discount_discount_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.discount_discount_id_seq OWNED BY public.discount.discount_id;


--
-- Name: event; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event (
    organiser_id integer NOT NULL,
    event_id integer NOT NULL,
    event_status_id integer NOT NULL,
    title character varying(64) NOT NULL,
    start_datetime timestamp without time zone NOT NULL,
    end_datetime timestamp without time zone,
    CONSTRAINT chk_event_chronology CHECK ((end_datetime > start_datetime))
);


--
-- Name: event_category; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event_category (
    event_id integer NOT NULL,
    category_id integer NOT NULL,
    event_category_id integer NOT NULL
);


--
-- Name: event_category_event_category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.event_category_event_category_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: event_category_event_category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.event_category_event_category_id_seq OWNED BY public.event_category.event_category_id;


--
-- Name: event_event_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.event_event_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: event_event_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.event_event_id_seq OWNED BY public.event.event_id;


--
-- Name: event_schedule_session; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event_schedule_session (
    event_id integer NOT NULL,
    schedule_id integer NOT NULL,
    session_title character varying(50),
    start_time timestamp without time zone,
    end_time timestamp without time zone,
    section_id integer NOT NULL,
    CONSTRAINT chk_session_chronology CHECK ((end_time > start_time))
);


--
-- Name: event_schedule_session_schedule_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.event_schedule_session_schedule_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: event_schedule_session_schedule_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.event_schedule_session_schedule_id_seq OWNED BY public.event_schedule_session.schedule_id;


--
-- Name: event_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event_status (
    event_status_id integer NOT NULL,
    status_name character varying(50) NOT NULL
);


--
-- Name: event_status_event_status_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.event_status_event_status_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: event_status_event_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.event_status_event_status_id_seq OWNED BY public.event_status.event_status_id;


--
-- Name: exhibitor; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.exhibitor (
    name character varying(50) NOT NULL,
    surname character varying(50),
    exhibitor_id integer NOT NULL,
    field_id integer NOT NULL
);


--
-- Name: exhibitor_event_schedule_session; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.exhibitor_event_schedule_session (
    exhibitor_id integer NOT NULL,
    event_schedule_session_id integer NOT NULL,
    start_time timestamp without time zone NOT NULL,
    end_time timestamp without time zone NOT NULL,
    exhibitor_event_schedule_session_id integer NOT NULL,
    CONSTRAINT chk_exhibitor_session_chronology CHECK ((end_time > start_time))
);


--
-- Name: exhibitor_event_schedule_sess_exhibitor_event_schedule_sess_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.exhibitor_event_schedule_sess_exhibitor_event_schedule_sess_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: exhibitor_event_schedule_sess_exhibitor_event_schedule_sess_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.exhibitor_event_schedule_sess_exhibitor_event_schedule_sess_seq OWNED BY public.exhibitor_event_schedule_session.exhibitor_event_schedule_session_id;


--
-- Name: exhibitor_exhibitor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.exhibitor_exhibitor_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: exhibitor_exhibitor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.exhibitor_exhibitor_id_seq OWNED BY public.exhibitor.exhibitor_id;


--
-- Name: field; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.field (
    field_id integer NOT NULL,
    field_name character varying(50) NOT NULL
);


--
-- Name: field_field_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.field_field_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: field_field_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.field_field_id_seq OWNED BY public.field.field_id;


--
-- Name: location; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.location (
    location_id integer NOT NULL,
    name character varying(100) NOT NULL,
    type_id integer NOT NULL,
    address character varying(255),
    city character varying(255) NOT NULL,
    capacity integer NOT NULL,
    CONSTRAINT chk_location_capacity CHECK ((capacity > 0))
);


--
-- Name: location_location_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.location_location_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: location_location_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.location_location_id_seq OWNED BY public.location.location_id;


--
-- Name: location_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.location_type (
    type_id integer NOT NULL,
    type_name character varying(100) NOT NULL
);


--
-- Name: location_type_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.location_type_type_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: location_type_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.location_type_type_id_seq OWNED BY public.location_type.type_id;


--
-- Name: order_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.order_status (
    status_id integer NOT NULL,
    status_name character varying(50) NOT NULL
);


--
-- Name: order_status_status_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.order_status_status_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: order_status_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.order_status_status_id_seq OWNED BY public.order_status.status_id;


--
-- Name: organiser; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.organiser (
    organiser_id integer NOT NULL,
    company_name character varying(255) NOT NULL,
    contact_phone character varying(50),
    website_url character varying(255)
);


--
-- Name: organiser_organiser_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.organiser_organiser_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: organiser_organiser_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.organiser_organiser_id_seq OWNED BY public.organiser.organiser_id;


--
-- Name: payment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.payment (
    order_id bigint NOT NULL,
    method_id integer NOT NULL,
    payment_id integer NOT NULL,
    amount_paid numeric(12,2),
    processed_at timestamp without time zone NOT NULL,
    transaction_id character varying(255) NOT NULL,
    is_refunded boolean,
    CONSTRAINT chk_payment_amount CHECK ((amount_paid >= (0)::numeric))
);


--
-- Name: payment_method; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.payment_method (
    method_id integer NOT NULL,
    method_name character varying(50) NOT NULL
);


--
-- Name: payment_method_method_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.payment_method_method_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: payment_method_method_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.payment_method_method_id_seq OWNED BY public.payment_method.method_id;


--
-- Name: payment_payment_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.payment_payment_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: payment_payment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.payment_payment_id_seq OWNED BY public.payment.payment_id;


--
-- Name: price_tier; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.price_tier (
    ticket_type_id integer NOT NULL,
    price numeric(10,2) NOT NULL,
    valid_from timestamp without time zone NOT NULL,
    valid_to timestamp without time zone NOT NULL,
    price_tier_id integer NOT NULL,
    CONSTRAINT chk_price CHECK ((price >= (0)::numeric)),
    CONSTRAINT chk_price_tier_chronology CHECK ((valid_to > valid_from))
);


--
-- Name: price_tier_price_tier_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.price_tier_price_tier_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: price_tier_price_tier_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.price_tier_price_tier_id_seq OWNED BY public.price_tier.price_tier_id;


--
-- Name: promo_code; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.promo_code (
    promo_code_id integer NOT NULL,
    code character varying(64) NOT NULL
);


--
-- Name: promo_code_promo_code_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.promo_code_promo_code_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: promo_code_promo_code_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.promo_code_promo_code_id_seq OWNED BY public.promo_code.promo_code_id;


--
-- Name: refund_request; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.refund_request (
    refund_request_id integer NOT NULL,
    reason text,
    requested_at timestamp without time zone NOT NULL,
    accepted_at timestamp without time zone,
    user_id bigint NOT NULL,
    payment_id integer NOT NULL
);


--
-- Name: refund_request_refund_request_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.refund_request_refund_request_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: refund_request_refund_request_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.refund_request_refund_request_id_seq OWNED BY public.refund_request.refund_request_id;


--
-- Name: review; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.review (
    user_id bigint NOT NULL,
    event_id integer NOT NULL,
    review_id integer NOT NULL,
    star_rating integer NOT NULL,
    review_text text,
    created_at timestamp without time zone NOT NULL,
    CONSTRAINT chk_star_rating CHECK (((star_rating >= 1) AND (star_rating <= 5)))
);


--
-- Name: review_review_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.review_review_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: review_review_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.review_review_id_seq OWNED BY public.review.review_id;


--
-- Name: seat; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.seat (
    seat_id integer NOT NULL,
    row_identifier character varying(10) NOT NULL,
    section_id integer NOT NULL,
    seat_number character varying(10) NOT NULL,
    is_accessible boolean NOT NULL,
    is_available boolean NOT NULL
);


--
-- Name: seat_seat_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.seat_seat_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: seat_seat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.seat_seat_id_seq OWNED BY public.seat.seat_id;


--
-- Name: section; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.section (
    section_id integer NOT NULL,
    section_name character varying(100),
    capacity integer NOT NULL,
    location_id integer NOT NULL,
    CONSTRAINT chk_section_capacity CHECK ((capacity > 0))
);


--
-- Name: section_section_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.section_section_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: section_section_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.section_section_id_seq OWNED BY public.section.section_id;


--
-- Name: sponsor; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sponsor (
    sponsor_id integer NOT NULL,
    name character varying(64) NOT NULL
);


--
-- Name: sponsor_event; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sponsor_event (
    event_id integer NOT NULL,
    sponsor_id integer NOT NULL,
    sponsor_event_id integer NOT NULL,
    sponsor_type character varying(64) NOT NULL,
    sponsor_amount_paid numeric(5,2) NOT NULL,
    CONSTRAINT chk_sponsor_amount CHECK ((sponsor_amount_paid >= (0)::numeric))
);


--
-- Name: sponsor_event_sponsor_event_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.sponsor_event_sponsor_event_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sponsor_event_sponsor_event_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.sponsor_event_sponsor_event_id_seq OWNED BY public.sponsor_event.sponsor_event_id;


--
-- Name: sponsor_sponsor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.sponsor_sponsor_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sponsor_sponsor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.sponsor_sponsor_id_seq OWNED BY public.sponsor.sponsor_id;


--
-- Name: sponsor_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sponsor_type (
    sponsor_type_id integer NOT NULL,
    sponsor_amount_paid numeric(5,2) NOT NULL,
    type character varying(64) NOT NULL,
    CONSTRAINT chk_sponsor_type_amount CHECK ((sponsor_amount_paid >= (0)::numeric))
);


--
-- Name: sponsor_type_sponsor; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sponsor_type_sponsor (
    sponsor_id integer NOT NULL,
    sponsor_type_id integer NOT NULL,
    sponsor_type_sponsor_id integer NOT NULL
);


--
-- Name: sponsor_type_sponsor_sponsor_type_sponsor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.sponsor_type_sponsor_sponsor_type_sponsor_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sponsor_type_sponsor_sponsor_type_sponsor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.sponsor_type_sponsor_sponsor_type_sponsor_id_seq OWNED BY public.sponsor_type_sponsor.sponsor_type_sponsor_id;


--
-- Name: sponsor_type_sponsor_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.sponsor_type_sponsor_type_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sponsor_type_sponsor_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.sponsor_type_sponsor_type_id_seq OWNED BY public.sponsor_type.sponsor_type_id;


--
-- Name: staff_member; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.staff_member (
    assigned_role integer NOT NULL,
    staff_member_id integer NOT NULL,
    name character varying(20) NOT NULL,
    surname character varying(20) NOT NULL,
    contact_phone character varying(50),
    staff_team_id integer NOT NULL
);


--
-- Name: staff_member_staff_member_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.staff_member_staff_member_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: staff_member_staff_member_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.staff_member_staff_member_id_seq OWNED BY public.staff_member.staff_member_id;


--
-- Name: staff_role; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.staff_role (
    staff_role_id integer NOT NULL,
    description character varying(100) NOT NULL
);


--
-- Name: staff_role_staff_role_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.staff_role_staff_role_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: staff_role_staff_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.staff_role_staff_role_id_seq OWNED BY public.staff_role.staff_role_id;


--
-- Name: staff_team; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.staff_team (
    staff_team_id integer NOT NULL,
    team_name character varying(50) NOT NULL
);


--
-- Name: staff_team_event_schedule; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.staff_team_event_schedule (
    schedule_id integer NOT NULL,
    shift_start timestamp without time zone NOT NULL,
    shift_end timestamp without time zone NOT NULL,
    is_available boolean DEFAULT true NOT NULL,
    staff_team_id integer NOT NULL,
    event_id integer NOT NULL,
    CONSTRAINT chk_shift_chronology CHECK ((shift_end > shift_start))
);


--
-- Name: staff_team_event_schedule_schedule_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.staff_team_event_schedule_schedule_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: staff_team_event_schedule_schedule_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.staff_team_event_schedule_schedule_id_seq OWNED BY public.staff_team_event_schedule.schedule_id;


--
-- Name: staff_team_staff_team_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.staff_team_staff_team_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: staff_team_staff_team_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.staff_team_staff_team_id_seq OWNED BY public.staff_team.staff_team_id;


--
-- Name: subscription_location; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subscription_location (
    user_id bigint NOT NULL,
    location_id integer NOT NULL,
    subscription_location_id integer NOT NULL,
    created_at timestamp without time zone NOT NULL
);


--
-- Name: subscription_location_subscription_location_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.subscription_location_subscription_location_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: subscription_location_subscription_location_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subscription_location_subscription_location_id_seq OWNED BY public.subscription_location.subscription_location_id;


--
-- Name: subscription_organiser; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subscription_organiser (
    user_id bigint NOT NULL,
    organiser_id integer NOT NULL,
    subscription_organiser_id integer NOT NULL,
    created_at timestamp without time zone NOT NULL
);


--
-- Name: subscription_organiser_subscription_organiser_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.subscription_organiser_subscription_organiser_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: subscription_organiser_subscription_organiser_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.subscription_organiser_subscription_organiser_id_seq OWNED BY public.subscription_organiser.subscription_organiser_id;


--
-- Name: ticket; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ticket (
    order_id bigint NOT NULL,
    ticket_id bigint NOT NULL,
    ticket_type_id integer NOT NULL,
    lock_expires_at timestamp without time zone NOT NULL,
    status character varying(50) NOT NULL,
    barcode_hash character varying(255) NOT NULL,
    seat_id integer,
    is_scanned boolean NOT NULL,
    scanned_at timestamp without time zone,
    is_presale boolean NOT NULL,
    CONSTRAINT chk_ticket_scanned_at_consistency CHECK ((((is_scanned = true) AND (scanned_at IS NOT NULL)) OR ((is_scanned = false) AND (scanned_at IS NULL))))
);


--
-- Name: ticket_ticket_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.ticket_ticket_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: ticket_ticket_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ticket_ticket_id_seq OWNED BY public.ticket.ticket_id;


--
-- Name: ticket_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ticket_type (
    event_id integer NOT NULL,
    ticket_type_id integer NOT NULL,
    tier_name character varying(100) NOT NULL,
    total_allocated integer NOT NULL,
    presale_start timestamp without time zone,
    presale_end timestamp without time zone,
    CONSTRAINT chk_presale_chronology CHECK ((presale_end > presale_start)),
    CONSTRAINT chk_ticket_allocated CHECK ((total_allocated >= 0))
);


--
-- Name: ticket_type_ticket_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.ticket_type_ticket_type_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: ticket_type_ticket_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.ticket_type_ticket_type_id_seq OWNED BY public.ticket_type.ticket_type_id;


--
-- Name: value; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.value (
    attribute_id integer NOT NULL,
    value_id integer NOT NULL,
    value_string text,
    value_int integer,
    value_datetime timestamp without time zone,
    value_bool boolean,
    event_id integer NOT NULL
);


--
-- Name: value_value_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.value_value_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: value_value_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.value_value_id_seq OWNED BY public.value.value_id;


--
-- Name: waitlist_entry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.waitlist_entry (
    waitlist_id bigint NOT NULL,
    joined_at timestamp without time zone NOT NULL,
    status character varying(20) NOT NULL,
    notified_at timestamp without time zone,
    expires_at timestamp without time zone,
    user_id bigint NOT NULL,
    event_schedule_session_id integer NOT NULL
);


--
-- Name: waitlist_entry_waitlist_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.waitlist_entry_waitlist_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: waitlist_entry_waitlist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.waitlist_entry_waitlist_id_seq OWNED BY public.waitlist_entry.waitlist_id;


--
-- Name: attribute attribute_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attribute ALTER COLUMN attribute_id SET DEFAULT nextval('public.attribute_attribute_id_seq'::regclass);


--
-- Name: category id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.category ALTER COLUMN id SET DEFAULT nextval('public.category_id_seq'::regclass);


--
-- Name: discount discount_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.discount ALTER COLUMN discount_id SET DEFAULT nextval('public.discount_discount_id_seq'::regclass);


--
-- Name: event event_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event ALTER COLUMN event_id SET DEFAULT nextval('public.event_event_id_seq'::regclass);


--
-- Name: event_category event_category_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_category ALTER COLUMN event_category_id SET DEFAULT nextval('public.event_category_event_category_id_seq'::regclass);


--
-- Name: event_schedule_session schedule_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_schedule_session ALTER COLUMN schedule_id SET DEFAULT nextval('public.event_schedule_session_schedule_id_seq'::regclass);


--
-- Name: event_status event_status_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_status ALTER COLUMN event_status_id SET DEFAULT nextval('public.event_status_event_status_id_seq'::regclass);


--
-- Name: exhibitor exhibitor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor ALTER COLUMN exhibitor_id SET DEFAULT nextval('public.exhibitor_exhibitor_id_seq'::regclass);


--
-- Name: exhibitor_event_schedule_session exhibitor_event_schedule_session_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session ALTER COLUMN exhibitor_event_schedule_session_id SET DEFAULT nextval('public.exhibitor_event_schedule_sess_exhibitor_event_schedule_sess_seq'::regclass);


--
-- Name: field field_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.field ALTER COLUMN field_id SET DEFAULT nextval('public.field_field_id_seq'::regclass);


--
-- Name: location location_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.location ALTER COLUMN location_id SET DEFAULT nextval('public.location_location_id_seq'::regclass);


--
-- Name: location_type type_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.location_type ALTER COLUMN type_id SET DEFAULT nextval('public.location_type_type_id_seq'::regclass);


--
-- Name: order_cart order_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_cart ALTER COLUMN order_id SET DEFAULT nextval('public."Order_order_id_seq"'::regclass);


--
-- Name: order_status status_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_status ALTER COLUMN status_id SET DEFAULT nextval('public.order_status_status_id_seq'::regclass);


--
-- Name: organiser organiser_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.organiser ALTER COLUMN organiser_id SET DEFAULT nextval('public.organiser_organiser_id_seq'::regclass);


--
-- Name: payment payment_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment ALTER COLUMN payment_id SET DEFAULT nextval('public.payment_payment_id_seq'::regclass);


--
-- Name: payment_method method_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_method ALTER COLUMN method_id SET DEFAULT nextval('public.payment_method_method_id_seq'::regclass);


--
-- Name: price_tier price_tier_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.price_tier ALTER COLUMN price_tier_id SET DEFAULT nextval('public.price_tier_price_tier_id_seq'::regclass);


--
-- Name: promo_code promo_code_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.promo_code ALTER COLUMN promo_code_id SET DEFAULT nextval('public.promo_code_promo_code_id_seq'::regclass);


--
-- Name: refund_request refund_request_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.refund_request ALTER COLUMN refund_request_id SET DEFAULT nextval('public.refund_request_refund_request_id_seq'::regclass);


--
-- Name: review review_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review ALTER COLUMN review_id SET DEFAULT nextval('public.review_review_id_seq'::regclass);


--
-- Name: seat seat_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.seat ALTER COLUMN seat_id SET DEFAULT nextval('public.seat_seat_id_seq'::regclass);


--
-- Name: section section_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.section ALTER COLUMN section_id SET DEFAULT nextval('public.section_section_id_seq'::regclass);


--
-- Name: sponsor sponsor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor ALTER COLUMN sponsor_id SET DEFAULT nextval('public.sponsor_sponsor_id_seq'::regclass);


--
-- Name: sponsor_event sponsor_event_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_event ALTER COLUMN sponsor_event_id SET DEFAULT nextval('public.sponsor_event_sponsor_event_id_seq'::regclass);


--
-- Name: sponsor_type sponsor_type_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_type ALTER COLUMN sponsor_type_id SET DEFAULT nextval('public.sponsor_type_sponsor_type_id_seq'::regclass);


--
-- Name: sponsor_type_sponsor sponsor_type_sponsor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_type_sponsor ALTER COLUMN sponsor_type_sponsor_id SET DEFAULT nextval('public.sponsor_type_sponsor_sponsor_type_sponsor_id_seq'::regclass);


--
-- Name: staff_member staff_member_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_member ALTER COLUMN staff_member_id SET DEFAULT nextval('public.staff_member_staff_member_id_seq'::regclass);


--
-- Name: staff_role staff_role_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_role ALTER COLUMN staff_role_id SET DEFAULT nextval('public.staff_role_staff_role_id_seq'::regclass);


--
-- Name: staff_team staff_team_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_team ALTER COLUMN staff_team_id SET DEFAULT nextval('public.staff_team_staff_team_id_seq'::regclass);


--
-- Name: staff_team_event_schedule schedule_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_team_event_schedule ALTER COLUMN schedule_id SET DEFAULT nextval('public.staff_team_event_schedule_schedule_id_seq'::regclass);


--
-- Name: subscription_location subscription_location_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_location ALTER COLUMN subscription_location_id SET DEFAULT nextval('public.subscription_location_subscription_location_id_seq'::regclass);


--
-- Name: subscription_organiser subscription_organiser_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_organiser ALTER COLUMN subscription_organiser_id SET DEFAULT nextval('public.subscription_organiser_subscription_organiser_id_seq'::regclass);


--
-- Name: ticket ticket_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket ALTER COLUMN ticket_id SET DEFAULT nextval('public.ticket_ticket_id_seq'::regclass);


--
-- Name: ticket_type ticket_type_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_type ALTER COLUMN ticket_type_id SET DEFAULT nextval('public.ticket_type_ticket_type_id_seq'::regclass);


--
-- Name: user_app user_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_app ALTER COLUMN user_id SET DEFAULT nextval('public."User_user_id_seq"'::regclass);


--
-- Name: value value_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.value ALTER COLUMN value_id SET DEFAULT nextval('public.value_value_id_seq'::regclass);


--
-- Name: waitlist_entry waitlist_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.waitlist_entry ALTER COLUMN waitlist_id SET DEFAULT nextval('public.waitlist_entry_waitlist_id_seq'::regclass);


--
-- Name: order_cart Order_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_cart
    ADD CONSTRAINT "Order_pkey" PRIMARY KEY (order_id);




--
-- Name: user_app User_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_app
    ADD CONSTRAINT "User_email_key" UNIQUE (email);


--
-- Name: user_app User_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_app
    ADD CONSTRAINT "User_pkey" PRIMARY KEY (user_id);


--
-- Name: attribute attribute_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attribute
    ADD CONSTRAINT attribute_pkey PRIMARY KEY (attribute_id);


--
-- Name: category category_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.category
    ADD CONSTRAINT category_name_key UNIQUE (name);


--
-- Name: category category_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.category
    ADD CONSTRAINT category_pkey PRIMARY KEY (id);


--
-- Name: discount discount_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.discount
    ADD CONSTRAINT discount_pkey PRIMARY KEY (discount_id);


--
-- Name: event_category event_category_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_category
    ADD CONSTRAINT event_category_pkey PRIMARY KEY (event_category_id);


--
-- Name: event event_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event
    ADD CONSTRAINT event_pkey PRIMARY KEY (event_id);


--
-- Name: event_schedule_session event_schedule_session_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_schedule_session
    ADD CONSTRAINT event_schedule_session_pkey PRIMARY KEY (schedule_id);


--
-- Name: event_status event_status_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_status
    ADD CONSTRAINT event_status_pkey PRIMARY KEY (event_status_id);


--
-- Name: event_status event_status_status_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_status
    ADD CONSTRAINT event_status_status_name_key UNIQUE (status_name);


--
-- Name: exhibitor_event_schedule_session exhibitor_event_schedule_session_event_schedule_session_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session
    ADD CONSTRAINT exhibitor_event_schedule_session_event_schedule_session_id_key UNIQUE (event_schedule_session_id);


--
-- Name: exhibitor_event_schedule_session exhibitor_event_schedule_session_exhibitor_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session
    ADD CONSTRAINT exhibitor_event_schedule_session_exhibitor_id_key UNIQUE (exhibitor_id);


--
-- Name: exhibitor_event_schedule_session exhibitor_event_schedule_session_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session
    ADD CONSTRAINT exhibitor_event_schedule_session_pkey PRIMARY KEY (exhibitor_event_schedule_session_id);


--
-- Name: exhibitor exhibitor_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor
    ADD CONSTRAINT exhibitor_pkey PRIMARY KEY (exhibitor_id);


--
-- Name: field field_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.field
    ADD CONSTRAINT field_pkey PRIMARY KEY (field_id);


--
-- Name: location location_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.location
    ADD CONSTRAINT location_pkey PRIMARY KEY (location_id);


--
-- Name: location_type location_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.location_type
    ADD CONSTRAINT location_type_pkey PRIMARY KEY (type_id);


--
-- Name: location_type location_type_type_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.location_type
    ADD CONSTRAINT location_type_type_name_key UNIQUE (type_name);


--
-- Name: order_status order_status_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_status
    ADD CONSTRAINT order_status_pkey PRIMARY KEY (status_id);


--
-- Name: order_status order_status_status_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_status
    ADD CONSTRAINT order_status_status_name_key UNIQUE (status_name);


--
-- Name: organiser organiser_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.organiser
    ADD CONSTRAINT organiser_pkey PRIMARY KEY (organiser_id);


--
-- Name: payment_method payment_method_method_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_method
    ADD CONSTRAINT payment_method_method_name_key UNIQUE (method_name);


--
-- Name: payment_method payment_method_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment_method
    ADD CONSTRAINT payment_method_pkey PRIMARY KEY (method_id);


--
-- Name: payment payment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment
    ADD CONSTRAINT payment_pkey PRIMARY KEY (payment_id);


--
-- Name: price_tier price_tier_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.price_tier
    ADD CONSTRAINT price_tier_pkey PRIMARY KEY (price_tier_id);


--
-- Name: promo_code promo_code_code_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.promo_code
    ADD CONSTRAINT promo_code_code_key UNIQUE (code);


--
-- Name: promo_code promo_code_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.promo_code
    ADD CONSTRAINT promo_code_pkey PRIMARY KEY (promo_code_id);


--
-- Name: refund_request refund_request_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.refund_request
    ADD CONSTRAINT refund_request_pkey PRIMARY KEY (refund_request_id);


--
-- Name: review review_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review
    ADD CONSTRAINT review_pkey PRIMARY KEY (review_id);


--
-- Name: seat seat_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.seat
    ADD CONSTRAINT seat_pkey PRIMARY KEY (seat_id);


--
-- Name: section section_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.section
    ADD CONSTRAINT section_pkey PRIMARY KEY (section_id);


--
-- Name: sponsor_event sponsor_event_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_event
    ADD CONSTRAINT sponsor_event_pkey PRIMARY KEY (sponsor_event_id);


--
-- Name: sponsor sponsor_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor
    ADD CONSTRAINT sponsor_name_key UNIQUE (name);


--
-- Name: sponsor sponsor_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor
    ADD CONSTRAINT sponsor_pkey PRIMARY KEY (sponsor_id);


--
-- Name: sponsor_type sponsor_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_type
    ADD CONSTRAINT sponsor_type_pkey PRIMARY KEY (sponsor_type_id);


--
-- Name: sponsor_type_sponsor sponsor_type_sponsor_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_type_sponsor
    ADD CONSTRAINT sponsor_type_sponsor_pkey PRIMARY KEY (sponsor_type_sponsor_id);


--
-- Name: staff_member staff_member_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_member
    ADD CONSTRAINT staff_member_pkey PRIMARY KEY (staff_member_id);


--
-- Name: staff_role staff_role_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_role
    ADD CONSTRAINT staff_role_pkey PRIMARY KEY (staff_role_id);


--
-- Name: staff_team_event_schedule staff_team_event_schedule_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_team_event_schedule
    ADD CONSTRAINT staff_team_event_schedule_pkey PRIMARY KEY (schedule_id);


--
-- Name: staff_team staff_team_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_team
    ADD CONSTRAINT staff_team_pkey PRIMARY KEY (staff_team_id);


--
-- Name: subscription_location subscription_location_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_location
    ADD CONSTRAINT subscription_location_pkey PRIMARY KEY (subscription_location_id);


--
-- Name: subscription_organiser subscription_organiser_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_organiser
    ADD CONSTRAINT subscription_organiser_pkey PRIMARY KEY (subscription_organiser_id);


--
-- Name: ticket ticket_barcode_hash_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket
    ADD CONSTRAINT ticket_barcode_hash_key UNIQUE (barcode_hash);


--
-- Name: ticket ticket_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket
    ADD CONSTRAINT ticket_pkey PRIMARY KEY (ticket_id);


--
-- Name: ticket_type ticket_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_type
    ADD CONSTRAINT ticket_type_pkey PRIMARY KEY (ticket_type_id);


--
-- Name: exhibitor_event_schedule_session uq_exhibitor_session; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session
    ADD CONSTRAINT uq_exhibitor_session UNIQUE (exhibitor_id, event_schedule_session_id);


--
-- Name: review uq_user_event_review; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review
    ADD CONSTRAINT uq_user_event_review UNIQUE (user_id, event_id);


--
-- Name: subscription_location uq_user_location_sub; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_location
    ADD CONSTRAINT uq_user_location_sub UNIQUE (user_id, location_id);


--
-- Name: subscription_organiser uq_user_organiser_sub; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_organiser
    ADD CONSTRAINT uq_user_organiser_sub UNIQUE (user_id, organiser_id);


--
-- Name: waitlist_entry uq_user_session_waitlist; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.waitlist_entry
    ADD CONSTRAINT uq_user_session_waitlist UNIQUE (user_id, event_schedule_session_id);


--
-- Name: value value_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.value
    ADD CONSTRAINT value_pkey PRIMARY KEY (value_id);


--
-- Name: waitlist_entry waitlist_entry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.waitlist_entry
    ADD CONSTRAINT waitlist_entry_pkey PRIMARY KEY (waitlist_id);


--
-- Name: discount fk_discount_promo; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.discount
    ADD CONSTRAINT fk_discount_promo FOREIGN KEY (promo_code_id) REFERENCES public.promo_code(promo_code_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: event_category fk_evcat_category; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_category
    ADD CONSTRAINT fk_evcat_category FOREIGN KEY (category_id) REFERENCES public.category(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: event_category fk_evcat_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_category
    ADD CONSTRAINT fk_evcat_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: event fk_event_organiser; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event
    ADD CONSTRAINT fk_event_organiser FOREIGN KEY (organiser_id) REFERENCES public.organiser(organiser_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: event fk_event_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event
    ADD CONSTRAINT fk_event_status FOREIGN KEY (event_status_id) REFERENCES public.event_status(event_status_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: exhibitor fk_exhibitor_field; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor
    ADD CONSTRAINT fk_exhibitor_field FOREIGN KEY (field_id) REFERENCES public.field(field_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: exhibitor_event_schedule_session fk_exsess_exhibitor; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session
    ADD CONSTRAINT fk_exsess_exhibitor FOREIGN KEY (exhibitor_id) REFERENCES public.exhibitor(exhibitor_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: exhibitor_event_schedule_session fk_exsess_session; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.exhibitor_event_schedule_session
    ADD CONSTRAINT fk_exsess_session FOREIGN KEY (event_schedule_session_id) REFERENCES public.event_schedule_session(schedule_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: location fk_location_type; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.location
    ADD CONSTRAINT fk_location_type FOREIGN KEY (type_id) REFERENCES public.location_type(type_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: order_cart fk_order_discount; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_cart
    ADD CONSTRAINT fk_order_discount FOREIGN KEY (discount_id) REFERENCES public.discount(discount_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: order_cart fk_order_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_cart
    ADD CONSTRAINT fk_order_status FOREIGN KEY (status_id) REFERENCES public.order_status(status_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: order_cart fk_order_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.order_cart
    ADD CONSTRAINT fk_order_user FOREIGN KEY (user_id) REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: payment fk_payment_method; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment
    ADD CONSTRAINT fk_payment_method FOREIGN KEY (method_id) REFERENCES public.payment_method(method_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: payment fk_payment_order; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payment
    ADD CONSTRAINT fk_payment_order FOREIGN KEY (order_id) REFERENCES public.order_cart(order_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: price_tier fk_pricetier_tickettype; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.price_tier
    ADD CONSTRAINT fk_pricetier_tickettype FOREIGN KEY (ticket_type_id) REFERENCES public.ticket_type(ticket_type_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: refund_request fk_refund_payment; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.refund_request
    ADD CONSTRAINT fk_refund_payment FOREIGN KEY (payment_id) REFERENCES public.payment(payment_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: refund_request fk_refund_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.refund_request
    ADD CONSTRAINT fk_refund_user FOREIGN KEY (user_id) REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: review fk_review_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review
    ADD CONSTRAINT fk_review_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: review fk_review_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review
    ADD CONSTRAINT fk_review_user FOREIGN KEY (user_id) REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: seat fk_seat_section; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.seat
    ADD CONSTRAINT fk_seat_section FOREIGN KEY (section_id) REFERENCES public.section(section_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: section fk_section_location; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.section
    ADD CONSTRAINT fk_section_location FOREIGN KEY (location_id) REFERENCES public.location(location_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: event_schedule_session fk_session_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_schedule_session
    ADD CONSTRAINT fk_session_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: event_schedule_session fk_session_section; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_schedule_session
    ADD CONSTRAINT fk_session_section FOREIGN KEY (section_id) REFERENCES public.section(section_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: sponsor_event fk_spev_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_event
    ADD CONSTRAINT fk_spev_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: sponsor_event fk_spev_sponsor; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_event
    ADD CONSTRAINT fk_spev_sponsor FOREIGN KEY (sponsor_id) REFERENCES public.sponsor(sponsor_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: sponsor_type_sponsor fk_sptypesp_sp; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_type_sponsor
    ADD CONSTRAINT fk_sptypesp_sp FOREIGN KEY (sponsor_id) REFERENCES public.sponsor(sponsor_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: sponsor_type_sponsor fk_sptypesp_type; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sponsor_type_sponsor
    ADD CONSTRAINT fk_sptypesp_type FOREIGN KEY (sponsor_type_id) REFERENCES public.sponsor_type(sponsor_type_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: staff_member fk_staff_role; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_member
    ADD CONSTRAINT fk_staff_role FOREIGN KEY (assigned_role) REFERENCES public.staff_role(staff_role_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: staff_member fk_staff_team; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_member
    ADD CONSTRAINT fk_staff_team FOREIGN KEY (staff_team_id) REFERENCES public.staff_team(staff_team_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: staff_team_event_schedule fk_staffsched_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_team_event_schedule
    ADD CONSTRAINT fk_staffsched_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: staff_team_event_schedule fk_staffsched_team; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.staff_team_event_schedule
    ADD CONSTRAINT fk_staffsched_team FOREIGN KEY (staff_team_id) REFERENCES public.staff_team(staff_team_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: subscription_location fk_subloc_loc; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_location
    ADD CONSTRAINT fk_subloc_loc FOREIGN KEY (location_id) REFERENCES public.location(location_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: subscription_location fk_subloc_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_location
    ADD CONSTRAINT fk_subloc_user FOREIGN KEY (user_id) REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: subscription_organiser fk_suborg_org; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_organiser
    ADD CONSTRAINT fk_suborg_org FOREIGN KEY (organiser_id) REFERENCES public.organiser(organiser_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: subscription_organiser fk_suborg_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subscription_organiser
    ADD CONSTRAINT fk_suborg_user FOREIGN KEY (user_id) REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: ticket fk_ticket_order; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket
    ADD CONSTRAINT fk_ticket_order FOREIGN KEY (order_id) REFERENCES public.order_cart(order_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: ticket fk_ticket_seat; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket
    ADD CONSTRAINT fk_ticket_seat FOREIGN KEY (seat_id) REFERENCES public.seat(seat_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: ticket fk_ticket_type; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket
    ADD CONSTRAINT fk_ticket_type FOREIGN KEY (ticket_type_id) REFERENCES public.ticket_type(ticket_type_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: ticket_type fk_tickettype_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ticket_type
    ADD CONSTRAINT fk_tickettype_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: value fk_value_attr; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.value
    ADD CONSTRAINT fk_value_attr FOREIGN KEY (attribute_id) REFERENCES public.attribute(attribute_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: value fk_value_event; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.value
    ADD CONSTRAINT fk_value_event FOREIGN KEY (event_id) REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: waitlist_entry fk_waitlist_session; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.waitlist_entry
    ADD CONSTRAINT fk_waitlist_session FOREIGN KEY (event_schedule_session_id) REFERENCES public.event_schedule_session(schedule_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: waitlist_entry fk_waitlist_user; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.waitlist_entry
    ADD CONSTRAINT fk_waitlist_user FOREIGN KEY (user_id) REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
--


