Re: are foreign keys realized as indexes? - Mailing list pgsql-general

From Lew
Subject Re: are foreign keys realized as indexes?
Date
Msg-id m4GdnaDx3PS4cNzbnZ2dnUVZ_jydnZ2d@comcast.com
Whole thread Raw
In response to Re: are foreign keys realized as indexes?  (Felix Kater <fkater@googlemail.com>)
Responses Re: are foreign keys realized as indexes?
List pgsql-general
Felix Kater wrote:
> I am not bound to indexes, however, wonder if foreign keys itself are
> non-atomic functionality. I mean: if foreign keys are based on some
> other lower level functionality like indexes or anything else which I
> could use as a substitute--in what way ever. Of course, I want to
> gain the same (referential integrity etc.).
>
> If foreign keys are, however, something unique which can't be replaced
> by any other pg function (I am of course not taking into account things
> like multiple queries bound together by transactions...) then I have to
> go though it and implement it into my pg interface (looking at the
> information_schema: This seems to be quite a bunch of work...).

Semantics are not a trivial thing.

Foreign keys are a fundamental semantic of the relational model.  They do not
mean the same thing as an index at all.

I find it strange that anyone would resist the notions of primary and foreign
keys, when they are the basis of the relational model.  Indexes aren't even
part of the relational model - they are a hack to enhance performance.

Sure they ultimately break down to machine instructions, but that's in a whole
different domain of discourse.  A data model is built up from primary keys,
foreign keys and dependent data.  They are fundamental.  They /are/ the
building blocks of your database.  Expressing these molecular concepts in
terms of their constituent atoms will not convey the molecular properties; you
lose a tremendous amount of information.

Just use the syntax that best expresses your structure: PRIMARY KEY and
FOREIGN KEY.

--
Lew

pgsql-general by date:

Previous
From: Gerard M
Date:
Subject: Re: Issue with database Postgresql :(
Next
From: Tom Lane
Date:
Subject: Re: Views- Advantages and Disadvantages