In developing a shopping cart application I've found that I needed to save settings and configurations based on the administrator's preferences and requirements. This information can be anything from company information, Shipping account IDs, PayPal API keys, notification preferences, etc.
在开发购物车应用程序时,我发现需要根据管理员的首选项和需求保存设置和配置。这个信息可以是任何东西,从公司信息,发货帐户id,贝宝API密钥,通知首选项,等等。
It seems highly inappropriate to create a table to store a single row in a relational database system.
创建一个表来存储关系数据库系统中的单个行似乎非常不合适。
What is the appropriate way to store this information?
存储这些信息的适当方式是什么?
Note: my DBMS is SQL Server 2008 and programming layer is implemented with ASP.NET (in C#).
注意:我的DBMS是SQL Server 2008,编程层是用ASP实现的。NET(c#)。
12 个解决方案
#1
162
I have done this two ways in the past - a single row table and a key/value pair table - and there are positives and negatives to each approach.
我过去用过这两种方法—单行表和键/值对表—每种方法都有优缺点。
Single Row
- positive: the values are stored in the correct type
- 正的:值存储在正确的类型中
- positive: it is easier to deal with in code (due to the above)
- 积极的:在代码中更容易处理(由于以上原因)
- positive: default values can be given to each setting individually
- 正:默认值可以分别给每个设置。
- negative: a schema change is required to add a new setting
- 否定:添加新设置需要模式更改
- negative: the table can become very wide if there are lots of settings
- 否定:如果有很多设置,桌子会变得很宽
Key/Value Pair
- positive: adding new settings does not require a schema change
- 积极的:添加新的设置不需要改变模式
- positive: the table schema is narrow, with extra rows being used for new settings
- 正的:表模式很窄,新设置使用了额外的行
- negative: each setting has the same default value (null/empty?)
- 负值:每个设置都有相同的默认值(null/empty?)
- negative: everything has to be stored as strings (ie. nvarchar)
- 否定:所有东西都必须以字符串形式存储。nvarchar)
- negative: when dealing with the settings in code, you have to know what type a setting is and cast it
- 否定:在处理代码中的设置时,您必须知道什么类型的设置并强制转换它
The single row option is by far the easiest one to work with. This is because you can store each setting in its correct type in the database and not have to store the types of the settings as well as their lookup keys in code.
单行选项是目前最容易使用的选项。这是因为您可以在数据库中以正确的类型存储每个设置,而不必在代码中存储设置的类型及其查找键。
One thing I was concerned with using this approach was having multiple rows in the "special" single row settings table. I overcame this by (in SQL Server):
使用这种方法时,我关心的一件事是在“特殊”单行设置表中有多个行。我通过(在SQL Server中):
- adding a new bit column with a default value of 0
- 添加一个默认值为0的新位列
- creating a check constraint to ensure that this column has a value of 0
- 创建检查约束以确保该列的值为0
- creating a unique constraint on the bit column
- 在位列上创建惟一的约束
This means that only one row can exist in the table because the bit column has to have a value of 0, but there can only be one row with that value because of the unique constraint.
这意味着表中只有一行可以存在,因为位列必须具有0的值,但是由于惟一的约束,只能有一行具有该值。
#2
9
You should create a table with a column for the information type and information value (at least). This way you avoid having to create new columns every time a new information is added.
您应该为信息类型和信息值(至少)创建一个包含列的表。这样可以避免每次添加新信息时都要创建新的列。
#3
5
A single row will work fine; it will even have strong types:
一行就可以了;它甚至会有很强的类型:
show_borders bit
admin_name varchar(50)
max_users int
One disadvantage is that it requires a schema change (alter table
) to add a new setting. One alternative is normalizing, where you end up with a table like:
一个缺点是它需要一个模式更改(alter table)来添加一个新的设置。另一种选择是标准化,最终得到的表格是:
pref_name varchar(50) primary key
pref_value varchar(50)
This has weak types (everything is a varchar), but adding a new setting is just adding a row, something you can do with just database write access.
这有弱类型(所有的都是varchar),但是添加一个新设置只是添加一行,您可以用数据库写访问来做一些事情。
#4
4
Personally, I would store it in a single row if that is what works. Overkill to store it in an SQL table? probably, but there is no real harm in doing so.
就我个人而言,如果这是可行的,我将把它存储在一行中。将它存储在SQL表中会过度吗?也许吧,但这样做并没有什么害处。
#5
3
You certainly don't have to change your schema when adding a new configuration parameter in the normalized approach, but you're still probably changing your code to process the new value.
当在规范化方法中添加新的配置参数时,您当然不需要更改模式,但是您仍然可能会更改代码以处理新值。
Adding an "alter table" to your deployment doesn't seem like that big of a tradeoff for the simplicity and type safety of the single row approach.
在您的部署中添加“alter table”似乎并不是为了简单和类型安全而进行的重大权衡。
#6
3
As you guessed, and except for the simplest situations, putting all configurations parameters in a single rows has many drawbacks. It is a bad idea...
正如您所猜测的,除了最简单的情况外,将所有配置参数放在一个行中有许多缺点。这是个坏主意……
A convenient way to store configuration and/or user preference type of information is in XML. Many DBMSes support the XML data type. The XML syntax allows you to expend the "language" and structure describing the configuration as this configuration evolves. One advantage of XML is its implicit support for hierarchical structure, allowing for example to store small lists of configuration parameters without having to name these with a numbered suffix. A possible drawback of XML format is that searching and generally modifying this data isn't as straight forward as other approaches (nothing complicated, but not as simple/natural)
存储配置和/或用户首选项类型信息的一种方便方法是使用XML。许多dbms支持XML数据类型。XML语法允许您扩展“语言”和描述配置的结构,以描述配置的演变。XML的一个优点是它对层次化结构的隐式支持,例如,允许存储小的配置参数列表,而不必使用编号后缀来命名它们。XML格式的一个可能的缺点是搜索和修改这些数据并不像其他方法那样直接(并不复杂,但也不简单/自然)
If you want to remain closer to relational model, the Entity-Attribute-Value model is probably what you need, whereby the individual values are stored in a table that typically looks like:
如果您想要更接近关系模型,那么实体-属性-值模型可能就是您所需要的,因此单个值存储在一个通常看起来如下的表中:
EntityId (foreign key to the "owner" of this attribute)
AttributeId (foreign key to the "metadata" table where the attribute is defined)
StringValue (it is often convenient to have different columns of different types
IntValue allowing to store the various attributes in a format that befits
them)
Whereby the AttributeId is a foreign key to a table where each possible Attribute ("configuration parameter" in your case) is defined, with say
属性id是表的外键,其中定义了每个可能的属性(如“configuration parameter”)
AttributeId (Primary Key)
Name
AttributeType (some code S = string, I = Int etc.)
Required (some boolean indicating that this is required)
Some_other_fields (for example to define in which order these attributes get displayed etc...)
Finally the EntityId allows you to identify some entity which "owns" these various attributes. In your case it could be a UserId or even just implicit if you only have one configuration to manage.
最后,EntityId允许您标识拥有这些不同属性的某个实体。在您的例子中,它可以是一个UserId,甚至是隐式的,如果您只有一个配置要管理的话。
Aside from allowing the list of possible configuration parameters to grow as the application evolves, the EAV model places the "meta data", i.e. the data pertaining to the Attribute themselves, in datatables, hence avoiding all the hard-coding of column names commonly seen when the configuration parameters are stored in a single row.
除了允许的可能的配置参数列表增长随着应用的发展,由模型的地方“元数据”,即数据与属性本身,在datatable中,因此避免所有列名常见的硬编码的配置参数存储在单个行。
#7
2
A Key and Value pair is similar to a .Net App.Config which can store configuration settings.
键和值对类似于。net App.Config,它可以存储配置设置。
So when you want to retrieve the value you could do:
所以当你想要检索你可以做的值时:
SELECT value FROM configurationTable
WHERE ApplicationGroup = 'myappgroup'
AND keyDescription = 'myKey';
#8
1
A common way to do this is to have a "properties" table simmular to a properties file. Here you can store all your app constants, or not so constant things that you just need to have around.
一种常见的方法是将“属性”表简化为属性文件。在这里,你可以存储所有的应用程序常数,或者不是你需要的常数。
You can then grab the info from this table as you need it. Likewise, as you find you have some other setting to save, you can add it in. Here is an example:
然后,您可以根据需要从该表中获取信息。同样地,当您发现您有一些其他设置要保存时,您可以添加它。这是一个例子:
property_entry_table
property_entry_table
[id, scope, refId, propertyName, propertyValue, propertyType]
1, 0, 1, "COMPANY_INFO", "Acme Tools", "ADMIN"
2, 0, 1, "SHIPPING_ID", "12333484", "ADMIN"
3, 0, 1, "PAYPAL_KEY", "2143123412341", "ADMIN"
4, 0, 1, "PAYPAL_KEY", "123412341234123", "ADMIN"
5, 0, 1, "NOTIF_PREF", "ON", "ADMIN"
6, 0, 2, "NOTIF_PREF", "OFF", "ADMIN"
This way you can store the data you have, and the data that you will have next year and don't know about yet :) .
通过这种方式,您可以存储您所拥有的数据,以及明年您将拥有但尚未了解的数据:)。
In this example, your scope and refId can be used for whatever you want on the back end. So if propertyType "ADMIN" has a scope 0 refId 2, you know what preference it is.
在本例中,您的范围和refId可以用于您希望在后端执行的任何操作。如果propertyType "ADMIN"的范围是0 refId 2,你知道它是什么偏好。
Property type comes in hand when, someday, you need to store non-admin info in here as well.
当有一天,您需要在这里存储非管理信息时,属性类型就会出现。
Note that you should not store cart data this way, or lookups for that matter. However if the data is System specific, then you can certainly use this method.
注意,不应该以这种方式存储cart数据,也不应该进行查找。但是,如果数据是特定于系统的,那么您当然可以使用这种方法。
For example: If you want to store your DATABASE_VERSION, you'd use a table like this. That way, when you need to upgrade the app, you can check the properties table to see what version of your software the client has.
例如:如果您想存储DATABASE_VERSION,您可以使用这样的表。这样,当您需要升级应用程序时,您可以检查properties表,查看客户端拥有的软件版本。
The point is you do not want to use this for things that pertain to the cart. Keep you business logic in well defined relational tables. The properties table is for system info only.
关键是,您不希望将它用于与购物车相关的东西。将业务逻辑保存在定义良好的关系表中。属性表仅用于系统信息。
#9
0
I'm not sure a single row is the best implementation for configuration. You might be better off having a row per configuration item with two columns (configName, configValue), although this will require casting all of your values to strings and back.
我不确定单个行是否是配置的最佳实现。您最好在每个配置项上都有一行,包含两列(configName, configValue),尽管这需要将所有的值转换为string和back。
Regardless, there's no harm in using a single row for global config. The other options for storing it in the DB (global variables) are worse. You could control it by inserting your first configuration row, then disabling inserts on the table to prevent multiple rows.
不管怎样,在全局配置中使用一行没有什么害处。在DB(全局变量)中存储它的其他选项更糟糕。您可以通过插入第一个配置行来控制它,然后禁用表上的插入来防止多行。
#10
0
You can do the Key/Value Pair without conversions by adding a column for each major type and one column telling you which column the data is in.
您可以通过为每个主要类型添加一个列,以及一个列告诉您数据所在的列来实现键/值对,而无需转换。
So your table would look something like:
所以你的表格看起来是这样的:
id, column_num, property_name, intValue, floatValue, charValue, dateValue
1, 1, weeks, 51, , ,
2, 2, pi, , 3.14159, ,
3, 4, FiscYearEnd, , , , 1/31/2015
4, 3, CompanyName, , , ACME,
It uses a little more room but at most you are using a few dozen attributes. You can use a case statement off the column_num value to pull / join the right field.
它使用了更多的空间,但最多使用几十个属性。您可以使用column_num值中的case语句来提取/加入正确的字段。
#11
0
Sorry I come like, yeaars later. But anyways, what I do is simple and effective. I simply create a table with three () columns:
对不起,我来了。但是无论如何,我所做的是简单而有效的。我只需创建一个包含三个()列的表:
ID - int (11)
ID - int(11)
name - varchar (64)
的名字——varchar(64)
value - text
价值——文本
What I do before creating a new config column, updating it or reading is to serialize the "value"! This way I am sure of the type (Well, php is :) )
在创建新的配置列、更新它或读取之前,我要做的是序列化“值”!这样我就确定了类型(php是:)
For instance:
例如:
b:0; is for BOOLEAN (false)
b:0;是布尔(假)
b:1; is for BOOLEAN (true)
b:1;是布尔(真正的)
i:1988; is for INT
我:1988;是整数
s:5:"Kader"; is for a STRING of 5 characters length
s:5:“就”;是5个字符长度的字符串吗
I hope this helps :)
我希望这能有所帮助。
#12
0
Have a key column as varchar and a value column as JSON. 1
is numeric whereas "1"
is a string. true
and false
are both boolean. You can have objects as well.
键列为varchar,值列为JSON。1是数字,而1是字符串。真与假都是布尔值。你也可以有对象。
#1
162
I have done this two ways in the past - a single row table and a key/value pair table - and there are positives and negatives to each approach.
我过去用过这两种方法—单行表和键/值对表—每种方法都有优缺点。
Single Row
- positive: the values are stored in the correct type
- 正的:值存储在正确的类型中
- positive: it is easier to deal with in code (due to the above)
- 积极的:在代码中更容易处理(由于以上原因)
- positive: default values can be given to each setting individually
- 正:默认值可以分别给每个设置。
- negative: a schema change is required to add a new setting
- 否定:添加新设置需要模式更改
- negative: the table can become very wide if there are lots of settings
- 否定:如果有很多设置,桌子会变得很宽
Key/Value Pair
- positive: adding new settings does not require a schema change
- 积极的:添加新的设置不需要改变模式
- positive: the table schema is narrow, with extra rows being used for new settings
- 正的:表模式很窄,新设置使用了额外的行
- negative: each setting has the same default value (null/empty?)
- 负值:每个设置都有相同的默认值(null/empty?)
- negative: everything has to be stored as strings (ie. nvarchar)
- 否定:所有东西都必须以字符串形式存储。nvarchar)
- negative: when dealing with the settings in code, you have to know what type a setting is and cast it
- 否定:在处理代码中的设置时,您必须知道什么类型的设置并强制转换它
The single row option is by far the easiest one to work with. This is because you can store each setting in its correct type in the database and not have to store the types of the settings as well as their lookup keys in code.
单行选项是目前最容易使用的选项。这是因为您可以在数据库中以正确的类型存储每个设置,而不必在代码中存储设置的类型及其查找键。
One thing I was concerned with using this approach was having multiple rows in the "special" single row settings table. I overcame this by (in SQL Server):
使用这种方法时,我关心的一件事是在“特殊”单行设置表中有多个行。我通过(在SQL Server中):
- adding a new bit column with a default value of 0
- 添加一个默认值为0的新位列
- creating a check constraint to ensure that this column has a value of 0
- 创建检查约束以确保该列的值为0
- creating a unique constraint on the bit column
- 在位列上创建惟一的约束
This means that only one row can exist in the table because the bit column has to have a value of 0, but there can only be one row with that value because of the unique constraint.
这意味着表中只有一行可以存在,因为位列必须具有0的值,但是由于惟一的约束,只能有一行具有该值。
#2
9
You should create a table with a column for the information type and information value (at least). This way you avoid having to create new columns every time a new information is added.
您应该为信息类型和信息值(至少)创建一个包含列的表。这样可以避免每次添加新信息时都要创建新的列。
#3
5
A single row will work fine; it will even have strong types:
一行就可以了;它甚至会有很强的类型:
show_borders bit
admin_name varchar(50)
max_users int
One disadvantage is that it requires a schema change (alter table
) to add a new setting. One alternative is normalizing, where you end up with a table like:
一个缺点是它需要一个模式更改(alter table)来添加一个新的设置。另一种选择是标准化,最终得到的表格是:
pref_name varchar(50) primary key
pref_value varchar(50)
This has weak types (everything is a varchar), but adding a new setting is just adding a row, something you can do with just database write access.
这有弱类型(所有的都是varchar),但是添加一个新设置只是添加一行,您可以用数据库写访问来做一些事情。
#4
4
Personally, I would store it in a single row if that is what works. Overkill to store it in an SQL table? probably, but there is no real harm in doing so.
就我个人而言,如果这是可行的,我将把它存储在一行中。将它存储在SQL表中会过度吗?也许吧,但这样做并没有什么害处。
#5
3
You certainly don't have to change your schema when adding a new configuration parameter in the normalized approach, but you're still probably changing your code to process the new value.
当在规范化方法中添加新的配置参数时,您当然不需要更改模式,但是您仍然可能会更改代码以处理新值。
Adding an "alter table" to your deployment doesn't seem like that big of a tradeoff for the simplicity and type safety of the single row approach.
在您的部署中添加“alter table”似乎并不是为了简单和类型安全而进行的重大权衡。
#6
3
As you guessed, and except for the simplest situations, putting all configurations parameters in a single rows has many drawbacks. It is a bad idea...
正如您所猜测的,除了最简单的情况外,将所有配置参数放在一个行中有许多缺点。这是个坏主意……
A convenient way to store configuration and/or user preference type of information is in XML. Many DBMSes support the XML data type. The XML syntax allows you to expend the "language" and structure describing the configuration as this configuration evolves. One advantage of XML is its implicit support for hierarchical structure, allowing for example to store small lists of configuration parameters without having to name these with a numbered suffix. A possible drawback of XML format is that searching and generally modifying this data isn't as straight forward as other approaches (nothing complicated, but not as simple/natural)
存储配置和/或用户首选项类型信息的一种方便方法是使用XML。许多dbms支持XML数据类型。XML语法允许您扩展“语言”和描述配置的结构,以描述配置的演变。XML的一个优点是它对层次化结构的隐式支持,例如,允许存储小的配置参数列表,而不必使用编号后缀来命名它们。XML格式的一个可能的缺点是搜索和修改这些数据并不像其他方法那样直接(并不复杂,但也不简单/自然)
If you want to remain closer to relational model, the Entity-Attribute-Value model is probably what you need, whereby the individual values are stored in a table that typically looks like:
如果您想要更接近关系模型,那么实体-属性-值模型可能就是您所需要的,因此单个值存储在一个通常看起来如下的表中:
EntityId (foreign key to the "owner" of this attribute)
AttributeId (foreign key to the "metadata" table where the attribute is defined)
StringValue (it is often convenient to have different columns of different types
IntValue allowing to store the various attributes in a format that befits
them)
Whereby the AttributeId is a foreign key to a table where each possible Attribute ("configuration parameter" in your case) is defined, with say
属性id是表的外键,其中定义了每个可能的属性(如“configuration parameter”)
AttributeId (Primary Key)
Name
AttributeType (some code S = string, I = Int etc.)
Required (some boolean indicating that this is required)
Some_other_fields (for example to define in which order these attributes get displayed etc...)
Finally the EntityId allows you to identify some entity which "owns" these various attributes. In your case it could be a UserId or even just implicit if you only have one configuration to manage.
最后,EntityId允许您标识拥有这些不同属性的某个实体。在您的例子中,它可以是一个UserId,甚至是隐式的,如果您只有一个配置要管理的话。
Aside from allowing the list of possible configuration parameters to grow as the application evolves, the EAV model places the "meta data", i.e. the data pertaining to the Attribute themselves, in datatables, hence avoiding all the hard-coding of column names commonly seen when the configuration parameters are stored in a single row.
除了允许的可能的配置参数列表增长随着应用的发展,由模型的地方“元数据”,即数据与属性本身,在datatable中,因此避免所有列名常见的硬编码的配置参数存储在单个行。
#7
2
A Key and Value pair is similar to a .Net App.Config which can store configuration settings.
键和值对类似于。net App.Config,它可以存储配置设置。
So when you want to retrieve the value you could do:
所以当你想要检索你可以做的值时:
SELECT value FROM configurationTable
WHERE ApplicationGroup = 'myappgroup'
AND keyDescription = 'myKey';
#8
1
A common way to do this is to have a "properties" table simmular to a properties file. Here you can store all your app constants, or not so constant things that you just need to have around.
一种常见的方法是将“属性”表简化为属性文件。在这里,你可以存储所有的应用程序常数,或者不是你需要的常数。
You can then grab the info from this table as you need it. Likewise, as you find you have some other setting to save, you can add it in. Here is an example:
然后,您可以根据需要从该表中获取信息。同样地,当您发现您有一些其他设置要保存时,您可以添加它。这是一个例子:
property_entry_table
property_entry_table
[id, scope, refId, propertyName, propertyValue, propertyType]
1, 0, 1, "COMPANY_INFO", "Acme Tools", "ADMIN"
2, 0, 1, "SHIPPING_ID", "12333484", "ADMIN"
3, 0, 1, "PAYPAL_KEY", "2143123412341", "ADMIN"
4, 0, 1, "PAYPAL_KEY", "123412341234123", "ADMIN"
5, 0, 1, "NOTIF_PREF", "ON", "ADMIN"
6, 0, 2, "NOTIF_PREF", "OFF", "ADMIN"
This way you can store the data you have, and the data that you will have next year and don't know about yet :) .
通过这种方式,您可以存储您所拥有的数据,以及明年您将拥有但尚未了解的数据:)。
In this example, your scope and refId can be used for whatever you want on the back end. So if propertyType "ADMIN" has a scope 0 refId 2, you know what preference it is.
在本例中,您的范围和refId可以用于您希望在后端执行的任何操作。如果propertyType "ADMIN"的范围是0 refId 2,你知道它是什么偏好。
Property type comes in hand when, someday, you need to store non-admin info in here as well.
当有一天,您需要在这里存储非管理信息时,属性类型就会出现。
Note that you should not store cart data this way, or lookups for that matter. However if the data is System specific, then you can certainly use this method.
注意,不应该以这种方式存储cart数据,也不应该进行查找。但是,如果数据是特定于系统的,那么您当然可以使用这种方法。
For example: If you want to store your DATABASE_VERSION, you'd use a table like this. That way, when you need to upgrade the app, you can check the properties table to see what version of your software the client has.
例如:如果您想存储DATABASE_VERSION,您可以使用这样的表。这样,当您需要升级应用程序时,您可以检查properties表,查看客户端拥有的软件版本。
The point is you do not want to use this for things that pertain to the cart. Keep you business logic in well defined relational tables. The properties table is for system info only.
关键是,您不希望将它用于与购物车相关的东西。将业务逻辑保存在定义良好的关系表中。属性表仅用于系统信息。
#9
0
I'm not sure a single row is the best implementation for configuration. You might be better off having a row per configuration item with two columns (configName, configValue), although this will require casting all of your values to strings and back.
我不确定单个行是否是配置的最佳实现。您最好在每个配置项上都有一行,包含两列(configName, configValue),尽管这需要将所有的值转换为string和back。
Regardless, there's no harm in using a single row for global config. The other options for storing it in the DB (global variables) are worse. You could control it by inserting your first configuration row, then disabling inserts on the table to prevent multiple rows.
不管怎样,在全局配置中使用一行没有什么害处。在DB(全局变量)中存储它的其他选项更糟糕。您可以通过插入第一个配置行来控制它,然后禁用表上的插入来防止多行。
#10
0
You can do the Key/Value Pair without conversions by adding a column for each major type and one column telling you which column the data is in.
您可以通过为每个主要类型添加一个列,以及一个列告诉您数据所在的列来实现键/值对,而无需转换。
So your table would look something like:
所以你的表格看起来是这样的:
id, column_num, property_name, intValue, floatValue, charValue, dateValue
1, 1, weeks, 51, , ,
2, 2, pi, , 3.14159, ,
3, 4, FiscYearEnd, , , , 1/31/2015
4, 3, CompanyName, , , ACME,
It uses a little more room but at most you are using a few dozen attributes. You can use a case statement off the column_num value to pull / join the right field.
它使用了更多的空间,但最多使用几十个属性。您可以使用column_num值中的case语句来提取/加入正确的字段。
#11
0
Sorry I come like, yeaars later. But anyways, what I do is simple and effective. I simply create a table with three () columns:
对不起,我来了。但是无论如何,我所做的是简单而有效的。我只需创建一个包含三个()列的表:
ID - int (11)
ID - int(11)
name - varchar (64)
的名字——varchar(64)
value - text
价值——文本
What I do before creating a new config column, updating it or reading is to serialize the "value"! This way I am sure of the type (Well, php is :) )
在创建新的配置列、更新它或读取之前,我要做的是序列化“值”!这样我就确定了类型(php是:)
For instance:
例如:
b:0; is for BOOLEAN (false)
b:0;是布尔(假)
b:1; is for BOOLEAN (true)
b:1;是布尔(真正的)
i:1988; is for INT
我:1988;是整数
s:5:"Kader"; is for a STRING of 5 characters length
s:5:“就”;是5个字符长度的字符串吗
I hope this helps :)
我希望这能有所帮助。
#12
0
Have a key column as varchar and a value column as JSON. 1
is numeric whereas "1"
is a string. true
and false
are both boolean. You can have objects as well.
键列为varchar,值列为JSON。1是数字,而1是字符串。真与假都是布尔值。你也可以有对象。