SQL Server – Moving Nullable Fields to Separate Table

database-diagramsnormalizationsql server

My website has a form page that has radio buttons yes|no corresponding to 7 questions. When the user selects yes, the user needs to specify a value (either a location, name, or medical condition, depending on the question).

However, I'm torn whether I should include the specified values in the same table as the answers.

One one hand, when I include the specified values into the same table as the answers, it is easier to query.

One the other hand, the specified values can have null values (when the user selects yes).

I went with the latter and made 7 tables for each of the specified values. Refer to this diagram:

schema

After looking at the table, I feel it's a bit of an overkill just for a simple functionality.

I would like suggestions as to what route should I go.

Should I merge everything into one table?

–OR–

Should I stick with this diagram?

Best Answer

Rather than stick with that table, would creating a question table work for your application? That is, instead of having a separate table for each question, have a question table as

CREATE TABLE question (question_id numeric, question text)

and instead of the AFE table linking to a bunch of other tables, create a separate answers table as

CREATE TABLE answers(question_id numeric, afe_id numeric, answer text)

That acts as a bridge between AFE and question. This lets you add new questions easier too.