У меня есть несколько вопросов, которые содержат вопросы. Я хотел бы сохранить в структуре данных, чтобы я мог выбрать дополнительный вопрос, когда пользователь выбирает первый вопрос. Кроме того, некоторые вспомогательные вопросы используют общие вопросы в этой категории. Первоначально я думал об использовании многомерного массива, но потом понял, что для поиска через массив потребуется довольно много времени.Тип структуры данных
Любое предложение приветствуется.
Спасибо
Это мое решение до сих пор.
//Key is the question and value(object) contains all the value related to the question
categoryToSubquestions[2] = {"What type of countertop?":{
"stone_slab_countertops": "Stone slab countertops",
"granite_countertops" : "Granite countertops",
"marble_countertops" : "Marble countertops",
"quartz_countertops" : "Quartz countertops",
"slate_countertops" : "Slate countertops",
"solid_surface_countertops" : "Solid Surface countertops",
"concrete_countertops" : "Concrete countertops",
"corian_countertops" : "Corian countertops",
"formica_countertops" : "Formica countertops",
"stainless_countertops" : "Stainless countertops",
"wood_or_butcher_block_countertops" : "Wood or Butcher block countertops",
"laminate_countertops" : "Laminate countertops",
"selectKey":"MappedCategory"
},
"What best describes your countertop project?":{
"install_or_replace": "Install or Replace",
"repair" : "Repair",
"selectKey":"describe_countertop_project"
},
"generalQuestions2": "4"
};
//This is general question that other categories might use...It is being used in the above category
generalQuestion[4] = {"Is this project part of a larger remodel?":{
"true" : "Yes",
"false": "No",
"selectKey":"part_of_larger_remodel"
}
};
//THIS IS categoryToSuquestion index to value assosciation...(JUST TO KEEP TRACK)
var keyValue = new Array(
/*0*/ "cabinets_reface",
/*1*/ "cabinets_refinish",
/*2*/ "cabinets_countertop_install");
У меня есть 70 из этого права сейчас, и я немного обеспокоен, если он будет замедляться, как только я буду добавлять дополнительные вопросы?
Звучит как дерево для меня. – ChaosPandion
Это может помочь привести пример (ы) вашей структуры данных. Я не уверен, что вы подразумеваете под «некоторыми вопросами, которые задают общие вопросы в этой категории». – showdev
Это все происходит на стороне клиента (javascript) или вы делаете что-либо из этого на стороне сервера из базы данных? –