Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

timgavin's avatar

Please share your opinion on my app design

I'm building an app which is basically a questionnaire; it consists of multiple sections, each having multiple sub-sections, with each of those containing multiple questions.

SECTION ONE
-- Heading One
---- Question 1
---- Question 2
---- Question 3

-- Heading Two
---- Question 1
---- Question 2
---- Question 3


SECTION TWO
-- Heading One
---- Question 1
---- Question 2
---- Question 3

-- Heading Two
---- Question 1
---- Question 2
---- Question 3

The user basically selects a section, then a heading, and then answers the questions.

There are approx. 400 questions in about 10 sections, so it's rather large. On top of this it needs to be localized, so I'm debating whether to build this in an array, or in a database, or using Laravel's localization.

An array would be fast and easily extensible, but not easily up-dateable by the client. I'd also have to hard-code the keys using integers, like auto-increments in mysql.

Storing in a database would be slower, but would allow for the client to more easily update each item. However, the client has said that's not a concern. I'm also thinking database would allow for the use of eloquent relationships. This may also get quite confusing with the tables and relationships...

I have very limited experience with Laravel localization. Would this be a better option? Would I just import() the files when I need them?

I'd appreciate any feedback you can give me on this.

Thanks!

0 likes
2 replies
Snapey's avatar

Absolutely store all data in the database, not in code. In this case, sections, headings and questions are all 'data'

I would probably have a questions bank, with fields that control the types of answer permitted yes/no, free form, 1-10, etc

Then a table of texts. Each text would have a questionID and a language. For any given question there would be multiple texts in the available languages.

Finally some form of question orchestration that determines the order that the questions appear in, and in what sections.

Once you have the database setup it should be very easy to define the views and list the questions in the correct language.

timgavin's avatar

Thanks for your help! Storing them in mySQL is actually how I had originally designed it - before I discovered Laravel and the "Laravel way." Your answer helped me decide I was on the right track. The answers are actually boolean, so no issues there.

In the process of designing it, but this is my start... Figuring out how all the pieces go together, relationships, etc...

sections
    id

section_translations
    id
    section_id
    lang
    text

headings
    id
    section_id

heading_translations
    id
    heading_id
    lang
    text

questions
    id

question_translations
    id
    question_id
    lang
    text

answers
    id
    user_id
    question_id
    answer [ enum ]

Please or to participate in this conversation.