[英]PHP/MYSQL: What should the best way to record any undefined optionals data from the user and optimized to search?
I have a table with some fixed columns id,title,created.., but there I need put some optional data from the user that I cant define a specif column, but I need this data for search from others users. 我有一个带有固定的id,title,created ..固定列的表,但是我需要从用户那里输入一些可选的数据,这些数据不能定义一个specif列,但是我需要这些数据以供其他用户搜索。 What the best way?
最好的方法是什么?
the data would be like key:value pair 数据就像是key:value对
What should the best way to record any undefined optionals data from the user and optimize to search? 记录用户未定义的可选数据并进行优化搜索的最佳方法是什么?
Good Day 美好的一天
Definitively 3). 明确地3)。 Storing a serialized array means being dependend on a language (php, json etc), and selecting via sql is impossible.
存储序列化数组意味着要依赖一种语言(php,json等),并且无法通过sql选择。 2) ist bad, because of several reasons;
2)不好,原因有几个; mainly, you are less flexible in extending and selecting.
主要是,您在扩展和选择方面不太灵活。 Create a meta table like 3), this is an established approach.
创建一个类似3)的元表,这是一种已建立的方法。
Update: 3) must be improved a bit: Create a table like this: 更新:3)必须进行一些改进:创建一个像这样的表:
UID | UID | key |
关键 value
值
not: 不:
UID | UID | key_value
核心价值
第三种方法是最好的,因为您可以轻松地在数据库中搜索,并且您不必担心每个用户有多少个值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.