Reputation: 5636
I'm just about to get into my nitty gritty of my game-changing -_- trivia app but I was wondering before i start my database (SQLite), how would my app know when an answer selected is correct? I was thinking that I could simply put a column in the database for the answer and then have 4 seperate columns for the answers choices, of which one would be repeated -then simply compare the answer selected to the answer of the current row. But this doesn't seem like the most elegant solution. I was simply wondering if there were other methods that I didn't know about.
I don't know if it's worth mentioning but the answers choices would be shuffled before finally being placed into textviews.
Upvotes: 0
Views: 184
Reputation: 2069
I would suggest giving each answer a numeric value (PK from database) and storing the number of the correct answer against the question row in the "questions" table.
As for checking the correct answer, do you really want to be going back to your database for each question? If you app takes off and is used by a lot of people your db is going to be put under a lot of strain. Perhaps have the app download the "round" (set of questions) definition and do the answer checking locally for each round, uploading the results afterwards.
Upvotes: 2