Re: INT array field referencing same table

Поиск
Список
Период
Сортировка
От Gareth Kirwan
Тема Re: INT array field referencing same table
Дата
Msg-id KMEELFAKJGHIGGNIDGHDIEACJPAA.gbjk@thermeoneurope.com
обсуждение исходный текст
Ответ на INT array field referencing same table  ("Gareth Kirwan" <gbjk@thermeoneurope.com>)
Список pgsql-admin
Correction:    The [] should have been after the INT, not the related :-)
Otherwise, as posted.
 
Gareth
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Gareth Kirwan
Sent: 23 October 2002 10:27
To: pgsql-admin@postgresql.org
Subject: [ADMIN] INT array field referencing same table

I just wanted to check that this is the right syntax for a table.
CREATE TABLE articles (
        id              INT PRIMARY KEY DEFAULT nextval('articles_seq'),
        category        INT,
        type            INT,
        title           VARCHAR(50),
        description     TEXT,
        link            INT,
        date    timestamp,
        related[]       INT,
        CONSTRAINT articles_categories_const FOREIGN KEY (category) REFERENCES a_categories (id) ON DELETE CASCADE,
        CONSTRAINT articles_types_const FOREIGN KEY (type) REFERENCES a_types (id) ON DELETE CASCADE,
        CONSTRAINT articles_links_const FOREIGN KEY (link) REFERENCES a_links (id) ON DELETE CASCADE,
        CONSTRAINT articles_related_const FOREIGN KEY (related) REFERENCES articles (id)
        );
The bit that I'm curious about is the related field.
Can I do it like this / Should I do it like this.
The array of integers should reference the id of the same table.
 
If anyone has any more general comments about the design, They'd be welcome too :-)
 
Should I index the date field if i expect it to be searched upon regularly ???
 
Thanks

Regards
 
Gareth Kirwan
Programming & Development,
Thermeon Europe Ltd,
gbjk@thermeoneurope.com
Tel: +44 (0) 1293 864 303
Thermeon Europe e-Card: gbjk

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

Предыдущее
От: "Gareth Kirwan"
Дата:
Сообщение: INT array field referencing same table
Следующее
От: "Gareth Kirwan"
Дата:
Сообщение: Re: INT array field referencing same table