Looooong DB table
I have this table that contains so many fields in Prisma, should I brake it up into multiple tables or it's fine like this?
7 Replies
First of all, what do you what to build?
I am building a quiz app
you should defintely split this up
first you should make a table with the quiz information
then a table with user info (or use an auth service for that)
and then a table that is linked to a quiz and user that shows the progress of each quiz that a user has done
but why not try your invention out and split your table up if you need to
There are some fields you can reduce - you don't really need a
successPercentage
and mark
field if you can calculate it based on (correct_answers * score_per_question)/(number_of_questions* score_per_question)
, also the solved
field is essentially producing the same result as success
or status
.So I should make three tables QuizInfo, UserAnswers, UserInfo, that makes sense I did like this before but it added a little more complexity so, I got lazy and did that way, but my way got complex too
Is it normal to have DB table this long? and what is the optimal length?
it depens on the project size
Just like Fleet said, it definitely depends on the project size
To me since it's a quiz app, the provided schema is okay
But you could try breaking it down, create two tables
One for the quiz, another to keep track of users answers
Just add a hidden row in the quiz table called OG answer. Then use it to check if user's answers match the OG answer in the quiz table