Re: A foreign key on a self-referring table

From: mAsterdam <mAsterdam_at_vrijdag.org>
Date: Fri, 05 Mar 2004 14:43:18 +0100
Message-ID: <40488400$0$568$e4fe514c_at_news.xs4all.nl>


Andrea Laforgia wrote:

> Thank you for all your answers.
>
> I was imagining it was weird just because I assumed that, whether, for
> a strange reason, a record pointed to itself, the DBMS would not allow
> to delete it. If I had, for instance:
>
> |--------------------------|
> |CustomerID = 100 |(PK)
> |--------------------------|
> |Name = .... |
> |City = ... |
> |ZipCode = ... |
> |CustomerID = 100 |(FK)
> ----------------------------
>
> Would the DBMS let delete that record ?

It has to be inserted first. Before that the table has to be created. That won't happen until there is a way to distinguish CustomerID (PK) from CustomerID (FK).

Naming attributes is a nice moment to contemplate *meaning*. The meaning of the CustomerID (PK) is assumedly (from the context) "A customer is identified by CustomerID". But what is the meaning of CustomerID (FK)? In other words: what hierarchy are you building? Received on Fri Mar 05 2004 - 14:43:18 CET

Original text of this message