存储在MySQL数据库数组的最佳方法? [英] Best way to store an array in MySQL database?

查看:595
本文介绍了存储在MySQL数据库数组的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的一部分包括歌曲音量自动化。

Part of my app includes volume automation for songs.

的体积自动化以下列格式中描述

The volume automation is described in the following format:

[[0,50],[20,62],[48,92]] 

我认为每个项目这个数组一个数据点含在歌曲的位置和含有0-100分的容积第二个值的第一个值

I consider each item in this array a 'data point' with the first value containing the position in the song and the second value containing the volume on a scale of 0-100.

然后我把这些价值观念和执行功能的客户端,以便创建一个贝塞尔曲线允许平滑过渡量为音频文件播放进行插值与虚拟数据点这一数据。

I then take these values and perform a function client-side to interpolate this data with 'virtual' data points in order to create a bezier curve allowing smooth volume transition as an audio file is playing.

然而,需要已经出现,以允许用户保存此自动化到数据库召回在稍后的日期

However, the need has arisen to allow a user to save this automation into the database for recall at a later date.

数据点可以是无限的(尽管在现实中应该从来没有真正超过大多数40-50左右小于10)

The datapoints can be unlimited (though in reality should never really exceed around 40-50 with most being less than 10)

另外我应该如何处理这些数据?它应该被存储为是,在文本字段?或者我应该处理它以某种方式事先获得最佳效果?

Also how should I handle the data? Should it be stored as is, in a text field? Or should I process it in some way beforehand for optimum results?

什么数据类型将是最好的MySQL中使用存储阵列?

推荐答案

绝对不是文本字段,但 VARCHAR - 也许。除非你想利用这些数据的数据库意义上,我不会建议分析的结果并将其存储在单独的列 - 统计学等

Definitely not a text field, but a varchar -- perhaps. I wouldn't recommend parsing the results and storing them in individual columns unless you want to take advantage of that data in database sense -- statistics etc.

如果你永远看不到自己在问什么是平均成交量用户使用?那就不必分析它。

If you never see yourself asking "What is the average volume that users use?" then don't bother parsing it.

要弄清楚如何存储这些数据问自己我怎么会用到它?如果你将获得阵列,需要用PHP来利用它,你可以使用连载功能。如果你将在JavaScript中使用的值,然后JSON编码可能会是最适合你(以及许多语言知道如何去code吧)

To figure out how to store this data ask yourself "How will i use it later?" If you will obtain the array and need to utilize it with PHP you can use serialize function. If you will use the values in JavaScript then JSON encoding will probably be best for you (plus many languages know how to decode it)

祝你好运!

这篇关于存储在MySQL数据库数组的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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