Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sAAyd-0082Eb-IO for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 16:07:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sAAyd-00E140-Km for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 16:07:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sAAyd-00E10U-8q for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 16:07:35 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sAAyZ-001e2C-44 for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 16:07:34 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2bde636ddc2so662365a91.1 for ; Thu, 23 May 2024 09:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716480450; x=1717085250; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=z5aElUxfP5667ssjPlITcg7qPMdxuf/LZ0wSIOgIrRk=; b=HGbKkGsAX7NWtDDjOVjL0B8igYJpuyxP3Mm/n7tJwqI6G6l5sYiQwSBwnCQKcxh0pa PkgC4TqU4ylZZ3Hcm3PSGKJHOGirtcIQZjkRAtfraqJqpGvUanvL3UexAPQtigp9XVBT uQiW+/A3OyWBdkZah9P/NrN7O9SjsACFHcQw4VTqw2jfv7jkBkYdIEAJF0TyKD/YCthP xWcoEq2uZqvZQbctA+1zikrMYbyKxj+ygNjkkD75UOGRjFfX6ln1HzI4uFt99IAdbUwv AAqJYwTfYPcjgvpAqHtctkD9d2XWiwWjncjED3Ggq5yZ3c1gLCnaHgcVYDmR7/a9/bO8 M8yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716480450; x=1717085250; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z5aElUxfP5667ssjPlITcg7qPMdxuf/LZ0wSIOgIrRk=; b=GZBN/H+PIWqCXTMFBAcvtq5IpVRnreyBfqOSQTd93kvHTsjhYpYgSJaBrkOPh0Ej8/ AqyN3uIRH+708Trh1e5++P8BAasduzxdI7g7WfrlcM9kWXEqcFRDRMLEMhBhT/uQhk/5 L9V18TY+aZZSc0vw+qcxq2uZ/MHNIW9hBb+Jd5XnXAOjSgpRl3avhHtINVMOwcRpR9Bn mkRhS4XPbQpGZTuOG2N0udKVKXRMJzS9WxVGuGZZ7+We9O4rDUiSEYudveT7fTcwLgRv EmePmberiCcNV4yUdSaq0wMjAMAVcgwTTgLueYbTrau+42aKg0iokygoHo0DMP8wN/pe Suow== X-Gm-Message-State: AOJu0YzVlk2eBU7OOHMaylFStyLW2jhRSd9dwmXfeUy/u3UQ8pVqAjSU xZFOzS6hE6K2ITogz7IeBK4BeiiZB83oi4GWL1JSx9pJg3yoTvrHl86bvSG8K143QC/3wPrWPtv nMd34Mkw/QTmpRAjhjXfCs0+dwd9U6zm3 X-Google-Smtp-Source: AGHT+IHbMQHEq3IMfSCWRoc/utRWJhKWXd7/skBR0O9VsbHarVgBvePeDV72yz82lPD5ZT/B9VE4OhtZTuhSYVbFUt4= X-Received: by 2002:a17:90a:38a5:b0:2bd:fadd:75e3 with SMTP id 98e67ed59e1d1-2bdfadd7689mr1157361a91.34.1716480449791; Thu, 23 May 2024 09:07:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Skorpeo Skorpeo Date: Thu, 23 May 2024 11:06:54 -0500 Message-ID: Subject: Re: Json table/column design question To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000079524c0619213f73" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000079524c0619213f73 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for the valuable feedback. I see people are big fans of json here. On Thu, May 23, 2024 at 3:04=E2=80=AFAM Laurenz Albe wrote: > On Wed, 2024-05-22 at 22:38 -0500, Skorpeo Skorpeo wrote: > > I was wondering if having unrelated columns in a table is a sound > approach when > > using json. In other words, if I have two collections of unrelated jso= n > objects, > > for example "Users" and "Inventory", would it be ok to have one table > with a > > "Users" column and a "Inventory" column? My concern is that from a row > > perspective the columns could be different lengths, such as more > inventory > > items as users. And for any given row the data in one column would hav= e > no > > relation to another column. I would only query a single column at a tim= e. > > > > Would this approach be ok or are there pitfalls such that it would be > > advantageous/recommended to have a separate table for each column? > > It doesn't matter much if you use one or two columns. > But the word "collection" makes me worry. Perhaps this article can give > you some ideas: > > https://www.cybertec-postgresql.com/en/json-postgresql-how-to-use-it-righ= t/ > > Yours, > Laurenz Albe > --00000000000079524c0619213f73 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for the valuable feedback.=C2=A0 I see people ar= e big fans of json here.

On Thu, May 23, 2024 at 3:04=E2=80=AFAM Laure= nz Albe <laurenz.albe@cybert= ec.at> wrote:
On Wed, 2024-05-22 at 22:38 -0500, Skorpeo Skorpeo wrote:
> I was wondering if having unrelated columns in a table is a sound appr= oach when
> using json.=C2=A0 In other words, if I have two collections of unrelat= ed json objects,
> for example "Users" and "Inventory", would it be o= k to have one table with a
> "Users" column and a "Inventory" column?=C2=A0 My = concern is that from a row
> perspective the columns could be different lengths, such as more inven= tory
> items as users.=C2=A0 And for any given row the data in one column wou= ld have no
> relation to another column. I would only query a single column at a ti= me.
>
> Would this approach be ok or are there pitfalls such that it would be<= br> > advantageous/recommended to have a separate table for each column?

It doesn't matter much if you use one or two columns.
But the word "collection" makes me worry.=C2=A0 Perhaps this arti= cle can give
you some ideas:

https://www.cybertec-post= gresql.com/en/json-postgresql-how-to-use-it-right/

Yours,
Laurenz Albe
--00000000000079524c0619213f73--