How an optional self referencing foreign key may be designed when part of the foreign key is also part of the referenced primary key.
In - Table Properties - Foreign Keys - uncheck Mandatory - Apply complains that FK cannot be optional because some columns are part of PK.
In column properties Mandatory is checked and grayed. Not possible to change.
This is not something I liked to see.
Reverse engineering such model marks the foreign key mandatory in the model. As it should not be. The other foreign key column is optional as it should.
CREATE TABLE TABLE_1
(
a NUMBER (4) NOT NULL ,
aversion NUMBER (4) NOT NULL ,
parentversion NUMBER (4)
)
;
ALTER TABLE TABLE_1
ADD CONSTRAINT TABLE_1_PK PRIMARY KEY ( a, aversion ) ;
ALTER TABLE TABLE_1
ADD CONSTRAINT TABLE_1_TABLE_1_FK FOREIGN KEY
(
a,
parentversion
)
REFERENCES TABLE_1
(
a,
aversion
)
;