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

AbdulBazith's avatar

Should I change my datastructure (specifically the questions-table) for online examination by the following tables.

Guys i have planned to do an application online examination.i need in help of table structure, kindly suggest me a better tale structure

my objective is iam an organization. i will bukly add questions and answers for online quiz examination and store it in db for later writing exams. i will explain my db structure.

my EduationStandardtable with fields

id  standard_name
1   CBSE
2   ICSE
3   Matriculation
4   State board
my classDetailstable with fields

id  class_name
1   5th std
2   6th std
3   7th std
my SubjectDetails table with fields

id  sub_name
1   english
2   maths
3   physics

Education standard is related to subjects in many to many relationship. class is related with subject with many to many relationship.

my ChapterDetails table with fields

id  subject_id      ChapterName
1   1               Matrices
2   1               Integration
3   1               Differentiation
4   3               Electrostatics
5   3               Tranformation
6   3               Electricity
my TopicDetails table with fields

id  chapter_id          Topic_id
1   1              Inverse of a Non-Singular
2   1             Elementary Transformations of a Matrix
3   1           Solving System of Linear Equations
4   4           Role of electrostatic
5   4           Electric flux
6   4           Polaraisation

subject has chapters with one to many and chapter has topics with one to many. So I planned to have my question table like this,

id
education_standard_id(fk)
class_id   (fk)
subject_id (fk)
chapter_id (fk)
topic_id (fk)
level (easy,medium,hard)
question_number
question_description
question_image(optional)
optionA:
optionA_image:(optional)
optionB:
optionB_image:(optional)
optionC:
optionC_image:(optional)
optionD:
optionD_image:(optional)
correctanswer
explanation
explanation_image (optional)
explanation_pdf (optional)
explanation-video(optional)

Is this enough? How else can I optimise this.

totally five tables class-table, subject-table, chapter -table, topic-table, question-table

is this format right?? else do i need to change.

0 likes
2 replies
bobbybouwmann's avatar

You can move the answers of the questions to a separate table and add an answer_id in your questions table that points to the correct table. However, that is optional. Your table structure looks fine to me.

It's hard to really help you here since I don't know any of the features of your application or how it will be built. Only the database structure is not enough information for that.

AbdulBazith's avatar

@bobbybouwmann thank you for your response.

yes i understood about you suggestion in answer and question table.

but may i know the difference between adding answer_id in question table which have a separate answer_table and adding question_id in answer table. both same only is there any difference??

next you said that db structure is not enough for guiding.

simply my one doubt, can i filter based on class, wise, subject wise, for this class these are the subjects, for this standard this are the subjects. for this subject these are the chapters like wise can i filter it from my above given db structure???

if i select a specific standard can i fetch its relevant subject, chapter, topic???

kindly dont hesitate and please answer for this??

Please or to participate in this conversation.