using tables as types in other tables - Mailing list pgsql-general

From Louis-David Mitterrand
Subject using tables as types in other tables
Date
Msg-id 20010214193539.A1374@apartia.ch
Whole thread Raw
List pgsql-general
In the app we are developing the concept of an address will occur very
often on many tables (vendor, clients, employees, etc.) so we are
looking to avoid code duplication by centralizing the addresses in one
table. However I once read on one of the pgsql- lists that one could use
a table name as a type:

create table address(street text, zip text, city text, country text);

create table employee(emp_addr address, emp_id int);

This is accepted by Postgres but the question is how to insert into the
employee table? What syntax should be used? I tried:

insert into employee values (('mystreet','myzip','mycity','mycountry'), 1);

But it doesn't work.

Should I proceed along that path or would I be better off using a
central address table with keys to the other tables?

Thanks in advance for your insight,


--
    THESEE: D'un perfide ennemi j'ai purg� la nature ;
            A ses monstres lui-m�me a servi de p�ture ;
                                          (Ph�dre, J-B Racine, acte 3, sc�ne 5)

pgsql-general by date:

Previous
From: Robert Dege
Date:
Subject: tmp_pg_shadow
Next
From: Tom Lane
Date:
Subject: Re: Backend sent D message without prior T