How to represent a bi-directional list in db?

Поиск
Список
Период
Сортировка
От Pankaj Jangid
Тема How to represent a bi-directional list in db?
Дата
Msg-id m2muew8l37.fsf@gmail.com
обсуждение исходный текст
Ответы Re: How to represent a bi-directional list in db?
Список pgsql-general
I am creating an application for a manufacturing scenario. To represent
stages in an assembly line, I wanted to create following table,

CREATE TABLE stages (
       id SERIAL PRIMARY KEY,
       name  VARCHAR(80) NOT NULL,
       created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
       updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
       prev_stage_id SERIAL REFERENCES stages NULL,
       next_stage_id SERIAL REFERENCES stages NULL,
       process_id SERIAL REFERENCES processes NOT NULL
);

But it:

Failed with: conflicting NULL/NOT NULL declarations for column
"prev_stage_id" of table "stages"

Is it not possible to create "nullable" self referencing foreign keys?

-- 
Pankaj Jangid



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

Предыдущее
От: Arup Rakshit
Дата:
Сообщение: Re: Extend inner join to fetch not yet connected rows also
Следующее
От: Francisco Olarte
Дата:
Сообщение: Re: How to represent a bi-directional list in db?