Re: How to deal with field on the database that stores variable array's?

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to deal with field on the database that stores variable array's?
Date: 2011-01-01 20:55:58
Message-ID: 4D1F94DE.1020308@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/01/11 12:35 PM, Andre Lopes wrote:
> Hi,
>
> I need to develop a database table that will aceept a variable array
> field. My doubt is how to deal with updates on the
> array field. How can I store the information of the array fields?
> There any examples on the Internet on how to deal with
> this subject?
>
> What I mean with variable array is:
>
>
> array(
> 'name' => 'Don',
> 'age' => '31'
> );
>
>
> array(
> 'name' => 'Peter',
> 'age' => '28',
> 'car' => 'ford',
> 'km' => '2000'
> );
>

thats very non-relational, and will make queries and updates very
difficult and messy, as well as making data integrity impossible to enforce.

is there a predetermined number of attributes, even if they may not be
present for a given entry? I would have a Person table which has all
the fields that most/all persons would have, like persons(id, name, age,
address, phone, etc), then for optional attributes a seperate table for
each attribute collection like car(person_id, brand, model, mileage,...).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dmitriy Igrishin 2011-01-01 21:23:18 Re: How to deal with field on the database that stores variable array's?
Previous Message Szymon Guz 2011-01-01 20:52:28 Re: How to deal with field on the database that stores variable array's?