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
heartbe troubled, neither let it be afraid." John 14:27