Jump to content

Database design for a "question of the day" type system


MrAdam

Recommended Posts

Hi All.I'm setting up a "question of the day" type system and would like some advice about the database design.Here's the current layout:

CREATE TABLE `question_settings` (  `question_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,  `question_title` varchar(255) NOT NULL,  PRIMARY KEY (`question_id`),  UNIQUE KEY `question_title` (`question_title`));

CREATE TABLE `question_answers` (  `answer_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,  `question_id` smallint(5) unsigned NOT NULL,  `answer_title` varchar(255) NOT NULL,  PRIMARY KEY (`answer_id`));

Think it's fairly self-explanatory, but is there a better way to do it? Whilst writing the queries to return the question and possible answers, using a join would require me to return the question for each answer. Or, I'd have to run two separate queries, 1 returning the question settings and the other to return all the answers.Seems to me there should be a better way of doing it.Thanks for any help..

Link to comment
Share on other sites

Those are the two ways of doing it. If you're displaying more than one question, it may make more sense to use a join. If you're displaying a single question, it's probably faster to do the two queries.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...