pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: BOURIAUD <david.bouriaud@ac-rouen.fr>
To: pgsql-sql@postgresql.org
Subject: About referential integrity.
Date: Mon, 25 Feb 2002 16:01:49 +0100
Message-ID: <200202251503.g1PF3vn21366@necker.ac-rouen.fr> (raw)

Hi there !
I've just subscribed to this list because I found something quite annoying 
about postgres and SQL querries as well.
Indeed, as far as I know, postgreSQL is reffered as a SGBD-R, the 'R' meaning 
relational.

Anyway, I don't understand why when tables are built with this referential 
integrity the back-end doesn't fullfill any request posted on those tables.

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 ???

If anyone have any clue about it, please let me know.

I know that this is not a postgreSQL bug, since there is NO SGBDR acting so 
(as far as I know anyway). But I'd like to know why such SGBD, said to be 
Relationnal don't do this by themselves.
Thanks for your clues and for having read me.
-- 
David BOURIAUD
----------------------------------------------------------
In a world without walls or fences, what use do we have 
for windows or gates ?
----------------------------------------------------------
ICQ#102562021




view thread (9+ messages)  latest in thread

Message-ID: <200202251503.g1PF3vn21366@necker.ac-rouen.fr>
Permalink:  ../200202251503.g1PF3vn21366@necker.ac-rouen.fr/
Also on:    postgresql.org/message-id/200202251503.g1PF3vn21366@necker.ac-rouen.fr

 · 

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: david.bouriaud@ac-rouen.fr
  Subject: Re: About referential integrity.
  In-Reply-To: <200202251503.g1PF3vn21366@necker.ac-rouen.fr>

* 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