1

I am building an application where users can apply for small business loans. There are 4 types of loans (A,B,C,D). There are 10 commons questions no matter which type they choose, but then based on which type of loan they want, there are 3-4 more questions specific for that type.

What is the best way to represent this in the database?

Thanks in advanced!

1

Consider having all questions in a single table. Have a column that is datatype SET with (currently) 4 "bits": 'A','B','C','D'. 10 questions would have all 4 bits set; the others would have one bit each.

(There are certainly other ways to solve this.)

0

For flexibility, I would have a many-to-many relationship between loan types and questions:

  • questions(question_id, question, ...)
  • loan_types(loantype_id, more field...)
  • loan_type_questions(loantypw_id, question_id, [order, other fields])

This way will allow you to

  • add more features later if needed. For example, depending on the loan type, you want the questions to show in a specific order. For this, you add order field in the relation table.
  • Add more question and/or loan types without having to modify the structure of the tables.

Again, as Rick mentioned, there are other, maybe better, ways :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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