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 1s9zTg-006opY-V5 for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 03:50:54 +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 1s9zTh-007Q3D-0f for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 03:50:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9zTg-007Q35-Md for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 03:50:52 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s9zTe-000JeR-1n for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 03:50:52 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5b2a66dce8fso4430162eaf.1 for ; Wed, 22 May 2024 20:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716436248; x=1717041048; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RiwZ4M087eY1pm/E61x8m+ULJ53AEH8qtypa3ZymxOg=; b=EWT20VugOjPf+gz9ajh6VMe+gbRdU3mbzc9aoRc8bvA03AoAKOE0NFamvOqiJ1xyB7 oi1wLAhzETBW/TAbf8Cv5hc3iJVQnWKLkUQKgtR6ry9CuGWhmfWlc5OdYD3DnAq96H7M KKi9DWDg9VS3mOxTB5BPwWodwESdgX9KoDF2PfLeaMrttQG6pG6vgbKqzkF/LVDloQj4 ZUI1XzRFKwrh35H0pLvDyQm+OPbwnBP4brpaIfPEDluqXJ17IPnAc99r6hUycBt3H0CM aT01yeV2UPxhqckPQWJCcPxdfk0SphQdPsrw9o7RKVWjg9aQ/44ZVNsOPzsIZ9VKp5Av wvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716436248; x=1717041048; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RiwZ4M087eY1pm/E61x8m+ULJ53AEH8qtypa3ZymxOg=; b=NwetS/FRvqzaWjKDjn2BV/qtJTIgfWvvUNz1nMfzXDNxnT2kKCdFzt0DxmuZ4kNonX c3BR/fhMQ28X3BYRkgXmr5Y76Y5lPkbUNCjBTbfT+TjFOIivEe4BTMqBBLtocvm21/WQ cGIDEA2z7u+ti2r5TQ8oLWx3OqzjJL/TuiFbaKiANl1AFgcszJ1G2gHQgDYCgrbbbJNL +1inKcFMHJD6XsBQv4LZ9vv8T3cjSyLUA+1OzwP8uuQLCq/ZPtwxqPMhguAWqrJDUQ9Z 3zbK1uYFCcg+YNloqnLp7nsdRyh41ciSp0T6AwjadtziddAq+W0nUyKdk4qgYPn+Yd/w Pnhg== X-Gm-Message-State: AOJu0YzKVb8uVhZZtIwprfocpkz6WO1IXFW/vehFt/0c1Mk//WK4pQ/1 wuT9W58b1bV8iloJjTh+v4ErcI/396W+/+nCkI+1094/XbL9CGj/NlhC41oQvesg8TNU0h0GKm6 QEqVZwIwWuCm2O4hInOLmHcVE448uUA== X-Google-Smtp-Source: AGHT+IGu4Fb1M3QQ4PlLFzurqhhIGpF/ii9SLgPrdid1uO3KodvjYXeBRQn2AQ7kuYRxuKcKhnue34ptd7UX9YbR0q0= X-Received: by 2002:a05:6820:81f:b0:5b6:3b6f:bf80 with SMTP id 006d021491bc7-5b6a0e0eef5mr4211247eaf.2.1716436248204; Wed, 22 May 2024 20:50:48 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:74d:0:b0:52c:cea1:1841 with HTTP; Wed, 22 May 2024 20:50:47 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Wed, 22 May 2024 20:50:47 -0700 Message-ID: Subject: Re: Json table/column design question To: Skorpeo Skorpeo Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000dad384061916f494" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000dad384061916f494 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wednesday, May 22, 2024, Skorpeo Skorpeo wrote: > Hi, > > I was wondering if having unrelated columns in a table is a sound approac= h > when using json. In other words, if I have two collections of unrelated > json 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 have no relation to another column. I would only query a > single column at a time. > > Would this approach be ok or are there pitfalls such that it would be > advantageous/recommended to have a separate table for each column? > > Any thoughts/inputs are greatly appreciated. > What do you expect to gain? The relational model and normalization has earned its longevity, I suggest you learn and apply those techniques. Which generally means avoiding json as a data type. (The single table abomination you describe isn=E2=80=99t even really on the table - you did a= fine job arguing against it yourself.) David J. --000000000000dad384061916f494 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wednesday, May 22, 2024, Skorpeo Skorpeo <skorpeo11@gmail.com> wrote:
Hi,

I was wondering if= having unrelated columns in a table is a sound approach when using json.= =C2=A0 In other words, if I have two collections of unrelated json objects,= for example "Users" and "Inventory", would it be ok 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 inventory items as users.=C2=A0 And for = any given row the data in one column would have no relation to another colu= mn. I would only query a single column at a time.

= Would this approach be ok or are there pitfalls such that it would be advan= tageous/recommended to have a separate table for each column?
Any thoughts/inputs are greatly appreciated.

What do you expect to gain?=C2=A0 The relational = model and normalization has earned its longevity, I suggest you learn and a= pply those techniques.=C2=A0 Which generally means avoiding json as a data = type. (The single table abomination you describe isn=E2=80=99t even really = on the table - you did a fine job arguing against it yourself.)
<= br>
David J.

--000000000000dad384061916f494--