null を許可する外部キーを持つincidentテーブルがあります。incidentTypeId(int)
表には とのincidentType2 つの列がId auto increment primary key not nullありincidentType not null nvarcharます。
このincidentTypeテーブルはDDL、「」の値listItemとして選択された「」を入力するためのものです。selected値が "" であるかどうかを確認しています。そうである場合はselectedValue、自分のDDLを null に設定しています。
DDLすべてから何かを選択すると、問題なく動作します。
insert何も選択されていない状態で試してみると、主キーであるnullためsqlexception on foreign key constraint、incidentType Id列に null を許可しない が設定されます。
nullを許可するにはどうすればよいですか?