Sunday, 15 April 2012

Database with either/or foreign key -



Database with either/or foreign key -

i have next table there either ldeviceid or mdeviceidas foreign key not both. best way handle this? making fields nullable suffice?

eventid primary key.

event(eventid, timestamp, data, support, ldeviceid*, mdeviceid*)

yes. if 2 fk columns nullable, must either set in valid fk or null. however, doesn't handle case seek set in both or neither. way enforce create insert/update trigger validates 1 null not both , raises exception validation fails.

database database-design foreign-keys

No comments:

Post a Comment