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 1sAB6U-0082uS-00 for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 16:15:43 +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 1sAB6T-00E6b5-2Z for pgsql-general@arkaria.postgresql.org; Thu, 23 May 2024 16:15:41 +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 1sAB6R-00E6ax-I8 for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 16:15:40 +0000 Received: from wfout4-smtp.messagingengine.com ([64.147.123.147]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sAB6K-001e5I-2L for pgsql-general@lists.postgresql.org; Thu, 23 May 2024 16:15:38 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.west.internal (Postfix) with ESMTP id 82E891C000AC; Thu, 23 May 2024 12:15:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 23 May 2024 12:15:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1716480929; x=1716567329; bh=juZtSweEIT2i+nYsY213Ji3iSXAm4bsD4tdLaYlJdWE=; b= b9p3akn4WT+RRzxL9ZH6MNJR3ZOJ8toOprLoFsZNr8Dl6ZL0Djpcv/qrXzGG1jGV l9HKLuol05k81ZU9fPVsUWaILQ47VI4cM+gPdrLLeCNIPI+pN2XnFpIsjxzFVOE4 NyLaLBjFfDu/psKEMtS0F4Wv7+o+NoOE5FjEf+JLOxUIo7QIm5tnMRDAnR6dPw83 V6AeytzC74rwrWxeve6cD5YCzJBiri9l1iiRCKxh3QvY79eaWwJWFEhrZAzV+S0k jCKe/j+IPg6lxIUjVlO3oub7YelNtRivHH5XKu114XEUFILNpkI06F6lcJ2rfQpF 4ap22CDZnsJW1zxCYm8s9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716480929; x= 1716567329; bh=juZtSweEIT2i+nYsY213Ji3iSXAm4bsD4tdLaYlJdWE=; b=m TSL4A7XQxZeR84NwKIXgsmgpqoQ+lTH0p95VGfa2Eoa/XyEm/zySQBQwhv8qGhdb trDHfQaCDUKg7BDHgXMEeEEDrGwySVhLDhihpSJkWP+y8mXogT9bpp7zxJJY96Hg w6xS1ZMJBvvReyRbfG6VYVFzM3E9gYtDMFv+TsMf/Dv8JbHBGfjhVxEVM4oRlPHr MOQB/x5yoNn31AKMgftjDgzlhEqdka+F+34SwjS1ErGUyz4Ful/M9C3dVeJXYdqL e7NGzSP6w9R7Kv1BeE5wr17F8kZDDG9yZFY6SPw4+qphoOOdrM7HMzqwilxIljqZ pdRM5W4BD9+3QaguHZucA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeiiedgleejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeeggfegvefhteefkefhuedvudefkeegleffgeehtdfh geehudejgfekjedvtdejffenucffohhmrghinheptgihsggvrhhtvggtqdhpohhsthhgrh gvshhqlhdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 May 2024 12:15:28 -0400 (EDT) Message-ID: <089015d7-ba30-4113-a29f-248caca375f7@aklaver.com> Date: Thu, 23 May 2024 09:15:27 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Json table/column design question To: Skorpeo Skorpeo , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/23/24 09:06, Skorpeo Skorpeo wrote: > Thank you for the valuable feedback.  I see people are big fans of json > here. You can be a fan of JSON and still think it is not the correct way to store data in a relational database. When you do that you often end up with nested, possibly unstructured, data sets. That ends up with the exertion of more effort to get the data out in any meaningful form and in a timely manner then the time and effort it would take to enter it in a structured way. > > On Thu, May 23, 2024 at 3:04 AM 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 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? > > 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-right/ > > Yours, > Laurenz Albe > -- Adrian Klaver adrian.klaver@aklaver.com