流程图逻辑 - 如何在DB中存储决策? [英] Flowchart logic - How to store decisions in DB?

查看:110
本文介绍了流程图逻辑 - 如何在DB中存储决策?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的所以我有一个流程图系统,型号为:



问题,最终结果,答案



一个问题有:

ID

清单< answer>

价值



答案有:

ID

NextQuestionID

CurrentQuestionID

结果ID

价值



结果有:

ID

价值



现在一些路线指向同一个问题(即2条路线可以指向问题ID 2)



目前加载问题,当单击答案时,它会传递nextQuestionId,这用于加载问题。现在答案然后由context.Answers(a => a.CurrentQuestionId == currentQuestion.Id)加载



问题是这个,可能有4-针对该questionID的6answers,但每个答案将路由到不同的地方。



任何人都可以想出一种方法来加载该问题的答案,而不必多次输入问题并给它一个不同的ID?

解决方案

基本上你是在尝试存储一个树形结构。



看看这些CP文章



一般树木持续存在关系数据库 [ ^ ]



SQL数据库中的树 [ ^

Ok so i've got a flowchart system, with models of:

Question,End Result, Answer

A Question has:
ID
List<answer>
Value

Answer has:
ID
NextQuestionID
CurrentQuestionID
ResultID
Value

Result has:
ID
Value

Now some of the routes point to the same question (i.e 2 routes can point to question ID 2)

at the moment to load the question, when a answer is clicked it passes a nextQuestionId and this is used to load the question. Now the answers are then loaded by context.Answers(a=> a.CurrentQuestionId == currentQuestion.Id)

problem is with this, there could be 4-6answers against that questionID, but each answer will route to somewhere diffferent.

Can anyone think of a way to load the answers for that Question, without having to type in the question more than once and giving it a different ID?

解决方案

Essentially you are trying to store a tree-structure.

Have a look at these CP articles

General trees persisted in relational databases[^]

Trees in SQL databases[^]


这篇关于流程图逻辑 - 如何在DB中存储决策?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆