Re: Arrays vs separate tables

Adrian Klaver <adrian.klaver@aklaver.com>

From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Rich Shepard <rshepard@appl-ecosys.com>, pgsql-general@postgresql.org
Date: 2025-10-19T20:50:32Z
Lists: pgsql-general
On 10/19/25 13:43, Rich Shepard wrote:

> In the former book I read that sometimes it's better to have multiple 
> values
> for an atribute in a single row by creating a separate table for that
> attribute rather than using the postgres array capability. The people table
> in my database (1706 rows) has two attributes using the array type
> (direct_phone and email), and only a few indivuals have multiple landline
> phone numbers (cell_phone is a separate column) or email addresses (office
> and personal?). Would it make sense for me to create new landline and email
> address tables and replace the array contents?

For direct_phone and email entries that have more then one value, how do 
you know what the values are pointing at e.g home vs office vs second 
office location, etc?

> 
> Other than remembering to use curly braces {} when entering data into an
> array column I don't think there'd be any performance benefit for making 
> the
> change. I'm curious to learn about arrays vs separate tables.
> 
> TIA,
> 
> Rich
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com