pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Contrepois <sokak@tin.it>
To: pgsql-sql@postgresql.org
Subject: Re: INSERT value of type table
Date: Wed, 30 May 2001 23:31:54 +0200
Message-ID: <9f3p0l$1pcq$1@news.tht.net> (raw)
References: <002501c0e4f4$d053cd40$71a337c1@ensma.fr>

> exemple:
> CRETAE TABLE Address (Number integer, Street varchar, city varchar, contry
> varchar);
> CREATE TABLE Person (Name varchar, addr Address);
> INSERT INTO addrerss VALUES ( 5, 'rue du pont',  'Lyon', 'France');
> The question is :
> How we can insert a new person whose address is that inserted in the
> table of the addresses.

CREATE TABLE Address (Number integer PRIMARY KEY, Street varchar, City
varchar, Country varchar)
CREATE TABLE Person (Name varchar, addr integer REFERENCES TO Address)

this is called a FOREIGN KEY.. look at some doc for it. this is the way
Relational DB works
bye
--
--

"L'idea di base è estremamente semplice..."
©opyright Frank "Pazzooo" Contrepois (schiavista francese del '900)






view thread (2+ messages)

Message-ID: <9f3p0l$1pcq$1@news.tht.net>
Permalink:  ../9f3p0l$1pcq$1@news.tht.net/
Also on:    postgresql.org/message-id/9f3p0l$1pcq$1@news.tht.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sokak@tin.it
  Subject: Re: INSERT value of type table
  In-Reply-To: <9f3p0l$1pcq$1@news.tht.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox