Should I add a Index Key in this case ? - Mailing list pgsql-sql

From Karen Goh
Subject Should I add a Index Key in this case ?
Date
Msg-id 1846839195.1533405.1571225796919@mail.yahoo.com
Whole thread Raw
Responses Re: Should I add a Index Key in this case ?
List pgsql-sql
Hi Experts,

I have a use case as follows : 

 add constraints to the database so that no two reservations for the same viewing may refer to the same seat.

So, say I have a primary key like this in the table A:


    SEAT_id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1
),
    CONSTRAINT A_pkey PRIMARY KEY (SEAT_id))
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

So, basically I would like to create a SEAT_Viewing_Id.

In this case, do I create a Index Key or ?

How should I construct or rather alter my table A to accomodate this SEAT_Viewing_Id ?

Hope someone can tell me how.

Furthermore, whenever an insertion is done via WebApp, I would have to insert the Index key as well or does PostgreSQL
willhave a way to increment the Index key which is the SEAT_Viewing_Id at the same time?
 

Thanks & regards,
Karen








pgsql-sql by date:

Previous
From: Mike Martin
Date:
Subject: Save Session?
Next
From: William Ivanski
Date:
Subject: Re: Save Session?