From: Oliver Elphick <olly@lfix.co.uk>
To: BOURIAUD <david.bouriaud@ac-rouen.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: About referential integrity.
Date: 25 Feb 2002 17:46:47 +0000
Message-ID: <1014659208.13241.6853.camel@linda> (raw)
In-Reply-To: <200202251503.g1PF3vn21366@necker.ac-rouen.fr>
References: <200202251503.g1PF3vn21366@necker.ac-rouen.fr>
On Mon, 2002-02-25 at 15:01, BOURIAUD wrote:
> Since I fear I'm not clear in the above, let me show you an example.
>
>
> Let's say I create two tables as shown below :
>
> create table t1
> (
> key1 serial PRIMARY KEY,
> field1 varchar(30)
> );
>
> create table t2
> (
> key2 serial not null PRIMARY KEY,
> key1 int4 references t1,
> field2 varchar(30)
> );
>
> As far as I know, t2 and t1 are linked together. If I want to select rows
> that belong to both tables, I would have to write something like this :
> select * from t1, t2 where t1.key1 = t2.key1;
>
> I think this is quite redundant, since I've created my tables so as to make
> sure that they would respect what is in the select above !!!!
>
>
> So, why souldn't I be abble to write :
> select * from t1, t2;
>
> and have the backend returns me only the rows that have t1.key1 = t2.key2 ???
That is not what SQL does.
The purpose of referential integerity is to ensure that a value in one
table corresponds to a row in another. It operates on database changes;
it does not extend to select queries.
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
"Peace I leave with you, my peace I give unto you; not
as the world giveth, give I unto you. Let not your
heart be troubled, neither let it be afraid."
John 14:27
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: olly@lfix.co.uk, david.bouriaud@ac-rouen.fr
Subject: Re: About referential integrity.
In-Reply-To: <1014659208.13241.6853.camel@linda>
* 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