Thahleel al-Aleem
Thahleel al-Aleem

Reputation: 771

A Null Foreign Key, is it suitable in this situation?

So lets say there's 3 tables, two tables with questions in them and 1 marking table, would it be suitable for a foreign key to be null at times?

So for example:

Question Table A (Questions from a source (Sources defined using another table)) Question Table B (Custom made questions (Sources defined using words))

Marking Table

When a question from Question Table A needs to be added to the Marking Table, would it be suitable to leave the foreign key field for Table B null as a question has already been selected from Table A?

Is there any way of making this more simple? I believe having the data in this arrangement makes it suitable.

Upvotes: 0

Views: 61

Answers (1)

Mohsen Heydari
Mohsen Heydari

Reputation: 7284

I think you may define a base table for Table-A and Table-B called Question, that will contain shared properties of questions.
Having Foreign key of Question table in Marking table will solve the problem. enter image description here

Upvotes: 1

Related Questions