预先感谢您对以下系统的数据库设计的任何想法。
我需要根据一些消息模板和参数列表自动生成一些消息,例如您好{0},您在{3}中是否有以下{1}、{2}中的任何一项?
{0}、{1}、{2}、{3} 均采用不同的数据类型,位于单独的表中。 {0} 可以是用户表中的名称,{1} {2} 可以是项目表中的名称,{3} 可以是其他表中的名称。
我需要存储所有的消息格式和带有填充参数的完整消息,这看起来不太容易。我正在考虑下表。还有更好的想法吗?谢谢!
Message_Format
===================================================================================
msgFormatID int
bodyFormat varchar e.g. "Do you have any of the following, {0}, {1}, {2} in {3}?"
Message_Details
======================
msgFormatID int
dataIndex int
specificTableName varchar => the table name of specific table corresponds to {0},{1}... e.g. User_Table
specificTypeName varchar => the column name of specific field, e.g. firstName in User_Table
specificTypeID int => the id used to query the table, e.g. userID
最佳答案
总的来说,它看起来是一个合理的设计,但我认为您还需要从源数据表中识别列和行。通过 Message_Details 的映射将需要特定的ColumnName。然后,您可以从特定表名称中选择特定列名称,但您仍然需要一种方法来选择您需要的行,但这可能需要来自您使用模板时的“环境”?在您的示例中,您将使用模板来确定 {0} 来自 SpecificTableName“userName”中的 SpecificColumnName“userName”,并且知道它是 SpecificTypeID 1=string(假设这就是该类型的用途),但是哪个用户呢?
关于mysql - 具有不同类型参数的消息模板的数据库设计?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17513853/