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 1n59G2-0001wJ-NG for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 16:35:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n59G1-0002rK-J6 for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 16:35:25 +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 1n59G0-0002rB-TB for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 16:35:25 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n59Fu-00024G-TN for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 16:35:23 +0000 Received: by mail-ed1-x52b.google.com with SMTP id f5so164364137edq.6 for ; Wed, 05 Jan 2022 08:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=kQhwFEkE7eCowW6ptxIvRJ0k0jJR6YTSnZlaSU3CyMw=; b=SSeFpqfElO0wMnTv055/V5f9qU0Y1WlSZfSB2EsdUtjUg1l6424IvxcE69hPv3e8t3 VPqvnO1E3xTeiCbtIUXrX9AA9yLzRmHKEfeZe6sqmfiIvGfQ4I0dV6ZTxJ69RMw2YLjc hgw74vYuAAJKSFat6HQiVMytJH7tuEAWrnohBdD6zXC4NmtgYx0WJNIpXk5+tLKD/0As pdEMYA3ttPfaPXiVk96bPuhSej3ZLlYiDfgioYZndc/y8+JupPk/K+1hLLbVGD+d6JK7 JuOuyTS+7eo02dk3ahCQ6Rn/gndDCOrjxQIjMJ+0OkhiCU6iw0+bUmaeQr/bsGEHjdhL 4MWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=kQhwFEkE7eCowW6ptxIvRJ0k0jJR6YTSnZlaSU3CyMw=; b=qaJ1cAqwsCkG2+x/fSC2WL0levNKM95Ojuz8EeoIY6OQVsWqK2dVsKENziMxGczdya RkyidDFqfxaSfhNHhngSc97Fl1vlkWlpNms9dpKDwhaXe12oVYiwiafE/B0NUZC3J6mL VzvgJpgTDiDBcnguf0aMYudcmK8RZTADQexrYqW2QZ+yJTV8pGE4GcNGs0oEqCte5FYY BRiLHy0ew3pTIyXJV5/KwNPQmso8z1VgN340rg+4AIjS6fls50NLUHthPS/Hu7wGnnW4 wbt/5wu8kR5Lurg6IO1B3RP/2tNpaRVk02lu36X1GQjzZZwtXmtkBFFAPSNN2RaxJQTP gx0Q== X-Gm-Message-State: AOAM532HHvFV2TTKSJnffed7kZ0Q9GDUZHWxbra4A3xhypahXfMnNnGH WFj1viVaVENc5Xv5H3J4JGYtIrxCdoMewhvGJPvYRVHUA6PbIigLxKzT4oTZnZL96yeQ5zdaY/w WqEPSDrVNszWg8sUwZitYyq6D5LCx5beX5MzRDVzwpZA2lymbtPqqF6xjYtgAMWfKTW0mNuIWKh Ozp5N5O7wQ/fa/CXFX1h+QOhaOnoDrpy5RCergFZYlpaKN8oReZQ12 X-Google-Smtp-Source: ABdhPJxRRbxGzKoaxIeGFnVRJU0Xl7wEXGgBzMpuorPY9UcV7FepRBlGrS75oT6CFk8s5Qb5ZKRauA== X-Received: by 2002:a50:a41e:: with SMTP id u30mr53094764edb.388.1641400517003; Wed, 05 Jan 2022 08:35:17 -0800 (PST) Received: from [10.137.0.18] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id h3sm4786879ede.78.2022.01.05.08.35.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jan 2022 08:35:16 -0800 (PST) Message-ID: Date: Wed, 5 Jan 2022 17:35:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: Create and access a dictionary type Content-Language: en-US To: Ron , pgsql-general@lists.postgresql.org References: From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company