-2

Here are two ways I can optimise mapping of a text field with several other attributes to question and answer. First approach is, creating a map table with both question_id and answer_id in which either of them will be null, and while querying I will query using column. In the second approach is normal like we would do normalisation.

Tables structures

Second approach will add one more table but in first approach there will be empty values against question_id and answer_id. Questions-

  1. Is it a good practice to leave cells blank?
  2. Will it have any performance issue?
  3. Will it violate any normalisation rule?
  4. ...
2
  • Why can't one use image to reference the condition? And after using all the normalisation, my question is out of way and it's not duplicate. It is about merging two normalised tables having one kind one common type of column. @philipxy, show your research before making this as duplicate and designating it as a basic. Commented Jun 5, 2020 at 9:02
  • There are no "cells" it database tables.
    – mustaccio
    Commented Jun 5, 2020 at 15:29

1 Answer 1

1

Step #1 is to decide clearly "What is your DB used for". Answer this:

  1. What is the way you/users write data in?
  2. What is the way users will query data out of the DB?
  3. What are your outputs? Other queries and representations of the data you will have inside.

  • If you are building just a storage for Q/A, one table is enough.
  • If you want to track multiple answers, or maybe a "chat", regarding the single question, two table are good to go. Table of questions (primary table) + table of answers (secondary table) with foreign key to the question (SQL DB approach).
  • If you are about to build a knowledge base, where one question can have multiple answers, based on "Symptoms" or something. Than in SQL it would involve 3 or more tables. (also consider using a Graph database or other NOSQL DB).
1
  • main purpose is to solve data redundancy and avoid same field type table column. I want to focus on the thing if leaving blank cells would be better than having two tables with same column type. Commented Jun 1, 2020 at 17:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.