X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 067DADA399 for ; Thu, 6 Oct 2005 08:25:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50934-01 for ; Thu, 6 Oct 2005 11:25:23 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 32860DA380 for ; Thu, 6 Oct 2005 08:25:23 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id B6E76414B80; Thu, 6 Oct 2005 12:25:17 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id B706815EDA; Thu, 6 Oct 2005 12:21:02 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 15383-10; Thu, 6 Oct 2005 12:20:58 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 045E915ED5; Thu, 6 Oct 2005 12:20:47 +0100 (BST) Message-ID: <4345088E.4090001@archonet.com> Date: Thu, 06 Oct 2005 12:20:46 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050912) X-Accept-Language: en-us, en MIME-Version: 1.0 To: xchris Cc: pgsql-sql@postgresql.org Subject: Re: Noob question about types and lists References: <1128595206.27646.18.camel@lyra> In-Reply-To: <1128595206.27646.18.camel@lyra> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/50 X-Sequence-Number: 22903 xchris wrote: > CREATE TYPE address AS > ( > street VARCHAR(160), > city INTEGER, > cap INTEGER, > country INTEGER (those are referring to other table) > ); > > and then composing table client > > CREATE TABLE client > ( > id SERIAL PRIMARY KEY, > name VARCHAR(80), > surname VARCHAR(80), > address address[3] > .... > UNIQUE (name,surname) > ); > > > This doesn't work. > I cannot create a list of types. > > I'm using a wrong syntax? or simply i cannot do this? From the manuals... 8.10. Arrays PostgreSQL allows columns of a table to be defined as variable-length multidimensional arrays. Arrays of any built-in or user-defined base type can be created. (Arrays of composite types or domains are not yet supported, however.) So - you can't do this at the moment. However - I don't think you want to anyway. If you're going to use a relational database, try a relational approach! Typically, you would do something like: CREATE TABLE client (id ..., name ...) CREATE TABLE address (id ..., street ...) CREATE TABLE client_address (client_id ..., address_id ...) Then, you can add some foreign-key constraints so PG makes sure that the ID numbers in client_address are all valid. This makes it simple to get client names, client addresses or both together. HTH -- Richard Huxton Archonet Ltd