Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Stephen Clutton
10,877 PointsPHP Project, help!
Hi!
I'm looking for some general advice for a project I would like to start. I'm pretty new to web development and would really appreciate any input.
I would like to create a web app, using PHP, for some of the guys at work to test their knowledge. The app would contain the following:
- 5 Topics, each with their own quiz
- 20 random questions from a table of 100 questions
- Multi choice answers, ranging from 2 - 5 answers
- The ability to save the answers once the quiz has ended.
- Be able to access the historic results for comparison.
I have looked into the MySQL database design and found the most popular set up would be for:
- Users
- Questions
- Question_Choices
- User_question_answer
I guess my question would be - does this setup seem viable? How would I be able to run different quizzes for each of the different topics?
Again, any input would be great! Thank you.
6 Answers
John W
21,558 PointsOps, I meant "Topics." Since you have 5, you can potentially have a topics table that looks like this:
topic_id | topic_name
1 | Business
2 | Technology
...
5 | Kitty
Then you can reference the topic_id in your questions table. The benefit is that if you ever end up changing the name of a topic, you won't have to change every single question in the topic. But then, it does add a layer of complexity to the database that could get annoying later. So it is really up to you.
John W
21,558 PointsLooks fine to me. If you want to fully normalize the tables, you can split the "category" out, but that's not totally necessary.
Stephen Clutton
10,877 PointsHey John
Thanks for your input - what do you mean by splitting out the categories? Using different tables??
Stephen Clutton
10,877 PointsAh I see, that seems sensible. Any idea how you could distinguish between various difficulties? Could you have a topics table and a difficulty table? You mention complexity, would this be too much?
John W
21,558 PointsI assume you are talking about the difficulties of individual question in your db.
A simple way to design this would be to define it on a scale, e.g. 1-10. As long as you don't name them or assign extra meta information for each level, all you need is an extra column in your question table.
Stephen Clutton
10,877 PointsPerfect, thank you for taking the time to help me out! I appreciate it.