Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA00920; Tue, 28 Jul 92 13:05:35 -0700
Message-Id: <9207282005.AA00920@postgres.Berkeley.EDU>
From: vis!bar!greg@UCSD.EDU
Subject: Arrays
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Date: Tue, 28 Jul 92 12:45:29 -0700
Sender: vis!bar!greg@UCSD.EDU

I've been thinking about arrays in Postgres, and the more that I've
thought about them the more they've bothered me, until I decided to
share my thoughts with you all.

Mathematically, an array is just a special kind of relation.  If
Postgres treated them in this general way (despite their being
implemented specially), there would be no question about how
to update specific elements, etc.  But then, what about the special
square bracket syntax for arrays?  It could be viewed as syntactic
sugar that was applicable to any relation of the appropriate form.

In more detail, I'm suggesting that relation[index] should apply to
any relation (including, but not limited to, special array relations)
which has only two fields.  Index would select on the first column and
the matching value in the second column would be returned.  It would
be an error if there were two matches, since arrays are functions.

This can be generalized to n-dimensional arrays by allowing
var.field[index_1,...,index_n] to select values from the (n+1)st (and
last) column of a relation given the values of fields 1-n.

Further generalizations are possible but the main advantage I see is
conceptually getting rid of arrays as special kinds of animals
demanding new features with each release.

Does this seem like a good idea?


_Greg


J. Greg Davidson	Institute for Software Research and Development
+1 (619) 452-8059       6231 Branting Street  San Diego, CA  92122  USA
 
vis!greg@nosc.mil					ucsd----+--vis
vis!greg@ucsd.edu		 			nosc----|

	*****************************************************
	*   Member of the League for Programming Freedom.   *
	*   For more info, write to league@prep.ai.mit.edu  *
	*****************************************************
