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 1n59bX-0002pJ-RM for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 16:57:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n59bW-0000VS-PB for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 16:57:38 +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 1n59bW-0000Ui-CG for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 16:57:38 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n59bU-0002E0-5Y for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 16:57:37 +0000 Received: by mail-ot1-x331.google.com with SMTP id r7-20020a05683001c700b005906f5b0969so31457ota.5 for ; Wed, 05 Jan 2022 08:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=MwVKcbe+VEwUC4d10/GgmTe+7HeTYBchagBvYoQ7SyM=; b=LuHEMNT+3SpL1/gaYpROBi1e/L56TaeTGztentRmAg4yYfKD/q91LCO5L01rkYv9bo okB4KNvxh5DyQuc0A4iJnjR2n8D2GcLl5DPdSYAR6pZS9+tui7y0i4fH/xWhUaSzhToL FGE7st6mxf6l2eXafSD2EFrqsrMtEq+wGmU4pXFSno6NwStQStuNfvPZz+UUFAHFeugU mGfxnRrBN29+jQ3OSml8X941neZG6JTDBXMvqZyCxrlXLwZ1ZHMiwEodp9sWAjf5PP+o XCNQr2TGG7+CNym6FsITipDIxF72ECYqpMqs3t6iZM7rNh03CQygcQ+KkD8bZ9yYXbVP ueKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=MwVKcbe+VEwUC4d10/GgmTe+7HeTYBchagBvYoQ7SyM=; b=cCQ5IYnQ+0p10dW0tdfWlDySy8X6JxFq/BnKHnkUNrOUhbppkNCAMF6Whu/zUYM5pQ ciuKh1BlMco+5Xgi3iWwx2mX5FKyDfOcqLInZVRGG5UlIKnAr1UBV+6DpCXoZKyP2PgM 8dAuFWJ9WgLCt1hIxNWVVCg/wTCQdNQRwwthi0xmexfqf777jVSgCIJcGoROYFMKvWFN NLjrZ3x0gbbPmfd/QyftIszwwWjW9dkVj9jHRWvtlGVo3CUHnrM7T4QsSDjSDHF9aE6y opgKyc8EjOqi5+PCztnx/tCvYiMY828u0LS+jHs58RgyDJiwtCQl3iq/1SOjhDNKrwn/ 5N/A== X-Gm-Message-State: AOAM5322Ty6CrJ3uLf4GzpPXbrfRaT/BPnWAkF/40RguSHsTzYazLYs+ DGuVvSQUd2LSumtQgIBK9hEXSQQzWvc= X-Google-Smtp-Source: ABdhPJyK3mNjqGRxLO/bRxuuKqV7dtEhhyJhYhVoRGaIPnAzyslODn0K+W4D9PA8RoxcRw97maBVkw== X-Received: by 2002:a9d:798f:: with SMTP id h15mr41027759otm.340.1641401855051; Wed, 05 Jan 2022 08:57:35 -0800 (PST) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id n18sm8514093ooj.30.2022.01.05.08.57.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jan 2022 08:57:34 -0800 (PST) Subject: Re: Create and access a dictionary type To: Tomas Vondra , pgsql-general@lists.postgresql.org References: From: Ron Message-ID: <71d93298-b172-9474-f3ff-96293a7f1524@gmail.com> Date: Wed, 5 Jan 2022 10:57:34 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/5/22 10:35 AM, Tomas Vondra wrote: > On 1/5/22 17:24, Ron wrote: >> On 1/5/22 7:22 AM, Tomas Vondra wrote: >>> On 1/5/22 14:17, Shaozhong SHI wrote: >>>> Any examples in Postgres to create a dictionary type to store and >>>> access key value pairs? >>>> >>> >>> I'd say JSONB can be used as an associative array, and e.g. in Python >>> can map to dict data type. >> >> The question confuses me.  Why isn't "create a table with Primary Key" >> the answer to "Any examples in Postgres to create a dictionary type to >> store and access key value pairs?" >> > > Well, yes - you can always decompose the dict and store it in an EAV, but > sometimes it's more convenient to just use "nested" dictionary at the row > level. Which is what a JSONB column does. Edgar Codd is rolling in his grave. -- Angular momentum makes the world go 'round.