using tables as types in other tables
От | Louis-David Mitterrand |
---|---|
Тема | using tables as types in other tables |
Дата | |
Msg-id | 20010214193539.A1374@apartia.ch обсуждение исходный текст |
Список | 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 по дате отправления: