Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nobO0-0006bH-Bz for pgsql-novice@arkaria.postgresql.org; Wed, 11 May 2022 01:43:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nobNz-0001w9-90 for pgsql-novice@arkaria.postgresql.org; Wed, 11 May 2022 01:43:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nobNy-0001vz-VZ for pgsql-novice@lists.postgresql.org; Wed, 11 May 2022 01:43:31 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nobNw-0005AU-37 for pgsql-novice@lists.postgresql.org; Wed, 11 May 2022 01:43:29 +0000 Received: by mail-ej1-x633.google.com with SMTP id gh6so1241471ejb.0 for ; Tue, 10 May 2022 18:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hMcGYyb5IYG822FF8bq8U5B7Yr19JbntPi1e243Hpc0=; b=JaaZDN4n+3LFY9oQ+6B0U8TQRJ+U54JJ63ajemzPgBBpRQ7frp0jQWy1T0Rcn8jI32 cQDuz0jeYa9U66fcOMKFbrVBS03BC1idVg0P6P4jyt1CkGUl0uCgNVxpLXlXFOohstAF pL/D7qLMabTviIuZvBFBujronB1HpItS+vVjgt/bpj7QfTTFyS0zsyI/3CMTvx7c5BML 1QMzPQP8o8GXgu8c11y2a+rhLUj79eunRtrvJxh1CQWD8Lt7V540MOGIZKec6kIWjGJC GQpnjwFeO8W13C40/ySZAyrj53x4bY0fnkRCl9xBE5oqFszM8gYPn+EHKZpKvBrK69mN Jztw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hMcGYyb5IYG822FF8bq8U5B7Yr19JbntPi1e243Hpc0=; b=RkILyzgESbwciDl17AFSEaRF5NX0Yn9GWLSzd1vMMffg4s6899sqEQhb1sfF98QXCs EAZ+HMYstXpGU1klG8GhI/l59MPKzAk8zR1JsF2zn/yYZcfQmObcYFV8o9H9bNm4Vv89 xH/v0k8R9V+Op8HHAxyy/TXZypG7jBsLueNezcUlHjPqfW0U7aH3ihK3ghCcsvXJTsnr bQW/bYdVHkTEc3LjtrkMp/VwXfZgHXBxdPSqTai0PCjs0tv2HUyUQoiiDyr7/aOOU+uz beliM6hbOOahRQOpbAL0VIW4SUMunO65dnI4kGsw3yi+Uhm9s82DiihcxumGxYigFYbj dLWA== X-Gm-Message-State: AOAM530mNmFnaZMMavvS3HRTNuXhb2xV7blqp+43sY5daqP0lfrc733v MINF13P6L+LUFLxAnsXRqvyg1im8soSD2FtwyjRsqyrh X-Google-Smtp-Source: ABdhPJwoGN707XMB8TntCVycIqYYmlj5l5Y3VLstB0AK9fPiz0pCuAhULjTKxsiVIBuHRJQvDopDQW7Vio9XB2Rt/cg= X-Received: by 2002:a17:907:3f26:b0:6f4:dc59:3cfe with SMTP id hq38-20020a1709073f2600b006f4dc593cfemr22445851ejc.528.1652233406474; Tue, 10 May 2022 18:43:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Tue, 10 May 2022 18:43:08 -0700 Message-ID: Subject: Re: Using "object orientated" tables? To: Simon Connah Cc: pgsql-novice Content-Type: multipart/alternative; boundary="00000000000047705105deb291f4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000047705105deb291f4 Content-Type: text/plain; charset="UTF-8" On Tue, May 10, 2022 at 6:33 PM Simon Connah wrote: > Hi, > > I was wondering what the community thought of using table inheritance in > PostgreSQL? Is it considered bad practice these days? > > Basically, I have a users table and every user has a unique, not null UUID > which is used as the primary key. There are only three columns on the > table. User ID, Username, Email. > > Having said that I'll have to store data about them which I don't want to > do in one massive table as it would be ugly as hell. So what I want is my > main user's table to stick to three columns and then sub-tables which > inherit from it to add their own column? So for instance I might want to > store an account balance for people making money on my site. > > Hopefully, I've managed to explain what I mean properly. If you need any > extra information then let me. > > I wouldn't use inheritance, especially since I do not want to carry around copies of Username and Email. Having a "core data" users table then adding additional one-to-one related tables based upon application needs is quite common. David J. --00000000000047705105deb291f4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, May 10, 2022 at 6:33 PM Simon Connah <simon.n.connah@protonmail.com= > wrote:
Hi,

I was wondering what the community thought of using table inheritance in Po= stgreSQL? Is it considered bad practice these days?

Basically, I have a users table and every user has a unique, not null UUID = which is used as the primary key. There are only three columns on the table= . User ID, Username, Email.

Having said that I'll have to store data about them which I don't w= ant to do in one massive table as it would be ugly as hell. So what I want = is my main user's table to stick to three columns and then sub-tables w= hich inherit from it to add their own column? So for instance I might want = to store an account balance for people making money on my site.

Hopefully, I've managed to explain what I mean properly. If you need an= y extra information then let me.


I wo= uldn't use inheritance, especially since I do not want to carry around = copies of Username and Email.=C2=A0 Having a "core data" users ta= ble then adding additional one-to-one related tables based upon application= needs is quite common.

David J.
<= /div> --00000000000047705105deb291f4--