Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iKhbj-0004U5-Eo for pgsql-sql@arkaria.postgresql.org; Wed, 16 Oct 2019 11:36:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iKhbh-0002Op-Qp for pgsql-sql@arkaria.postgresql.org; Wed, 16 Oct 2019 11:36:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iKhbh-0002OW-A0 for pgsql-sql@lists.postgresql.org; Wed, 16 Oct 2019 11:36:45 +0000 Received: from sonic315-13.consmr.mail.bf2.yahoo.com ([74.6.134.123]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iKhbf-0002Ri-0u for pgsql-sql@lists.postgresql.org; Wed, 16 Oct 2019 11:36:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1571225801; bh=zHjcIo6QR05Bquc2ip1ua+lijXjbM1gJA6MbWOdMMEM=; h=Date:From:To:Subject:From:Subject; b=s/j5gzpNlJxi4W76M8yTp0C3CrvYgtWqzvv96hH0FvpLSMyX3fOFtQVfQC/HZyt33rynV3U5gE4wo83Wp4WQ6F1YaeO3/eULm9EjFtLQuEUajx3fyz5rKzJHOoiu8TANNjZyFlW2zduY1mD+Q1JpgyH9AW/FreiOQLS+vL2Svc5z1payIctfYJ7ATJZeElE6zfwbWc1w5FfycVm9ZINR39Kav3nwQ9iOBtQ6bmn1PWWuLPAayjE0sgDGPA4LDp2BvWwKDdptSIxjMd/1WKlKCM6pAt8q9FilNi+gjm7CVNnILemandKDEMmVPy0YQa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CmuIOx7jMSn6pAF4AwnrQcN2_C8QUpJ9yTCDtCnSpHsB3XMLuPlsLNNmEWygHECWvx.zHTTAi4F hNn.wrSFjoYgYelgx7djAnLSQ9orDjU4op7WjDh67TEB3KEc57Zjmy7ILaEIAvTl_qdv8DJ48TqT aCqLjZ8du5o5UMIqDkTP0BCkJOO35DprfqUHCQNDsC5usK5l8BN9JyRWYe_ecxJSv1n7H.u0ppQI vV1_JBFGqNoIVafsw15nhgmLI1IvjGYGQx_j4J6xqtLtqS7n6nFFH0Gv3WSuvYgWX72hq Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.bf2.yahoo.com with HTTP; Wed, 16 Oct 2019 11:36:41 +0000 Date: Wed, 16 Oct 2019 11:36:36 +0000 (UTC) From: Karen Goh To: pgsql-sql@lists.postgresql.org Message-ID: <1846839195.1533405.1571225796919@mail.yahoo.com> Subject: Should I add a Index Key in this case ? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 890 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 will have a way to increment the Index key which is the SEAT_Viewing_Id at the same time? Thanks & regards, Karen