Re: Referential integrity (foreign keys) across multiple tables

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Referential integrity (foreign keys) across multiple tables
Дата
Msg-id 20060724175148.GA25994@wolff.to
обсуждение исходный текст
Ответ на Re: Referential integrity (foreign keys) across multiple tables  (Richard Jones <rich@annexia.org>)
Ответы Re: Referential integrity (foreign keys) across multiple tables
Список pgsql-sql
On Mon, Jul 24, 2006 at 09:59:07 +0100, Richard Jones <rich@annexia.org> wrote:
> On Sun, Jul 23, 2006 at 01:32:37PM -0500, Bruno Wolff III wrote:
> > On Sat, Jul 22, 2006 at 14:32:57 +0100,
> >   Richard Jones <rich@annexia.org> wrote:
> > > 
> > > Now I want to add a column to page_contents, say called link_name,
> > > which is going to reference the pages.url column for the particular
> > > host that this page belongs to.
> > 
> > What are you trying to accomplish by this?
> 
> Data integrity.

This doesn't make sense in isolation. If that is all you are trying to do,
then you don't need to do anything to the database design as the information
is already there. The application just needs to do a join when querying the
data.

> > The information is available by doing a join. If you are trying to
> > simplify things for applications, you can probably do it with a view
> > or rules depending on whether you want to have an updatable view. If
> > you are denormalizing for performance and want constraints to
> > maintain consistancy, then you probably want to push the hostid down
> > to page_contents as well as the url. These could both be set with a
> > trigger. (I think a rule could be used as well.)
> 
> So if I get this right, I should use a trigger to ensure that the old
> code causes the hostid field to be set in page_contents?

No unless you are trying to do something else in addition to maintaining
data integrity.


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Aaron Bono"
Дата:
Сообщение: Re: Referential integrity (foreign keys) across multiple tables
Следующее
От: Richard Jones
Дата:
Сообщение: Re: Referential integrity (foreign keys) across multiple tables