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