最佳 MySQL 数据类型
我正在尝试找到一种将这一系列点存储在数据库中的好方法。
我认为好的几种方法是首先使用文本类型,然后使用分隔符来分隔点,这样它在数据库中看起来就像这样
+----------------------------+
| x_points | 1:2:3:4:5... |
| y_points | 1:2:3:4:5... |
+----------------------------+
,然后网络应用程序将拉出点并将它们绘制在画布上。
有没有更好的方法将点存储到数据库中的一行?
对于复杂函数,每个图可能有 1000 个点,然后每个点都有一个分隔符,因此有大量字符。
由于评论,我将尝试更详细地阐述。我正在使用画布绘制用户输入的函数。用户还可以在图表上绘图,我也想存储绘图的线条数据,我认为可以以相同的方式存储,并且点的计算只需要发生一次。
示例 seniro 是用户可以绘制 y=x^2,然后圈出 y 截距。然后他们可以链接到该画布,它会重新绘制 y 轴截距和图形的圆。当然,这是一个简单的示例,但我无法弄清楚如何最好地将点存储在画布上。
希望这有更多帮助。
I am trying to figure a good way to store these a series of points in a database.
The couple ways I thought would be good is first a text type and then use a delimiter to sperate the points so it would look like this in the db
+----------------------------+
| x_points | 1:2:3:4:5... |
| y_points | 1:2:3:4:5... |
+----------------------------+
Then the web app would pull the points and plot them on a canvas.
Is there a better way to store points to a line in a db?
For complex functions the points could be 1000 points per graph and then a delimiter for each point so a boat load of characters.
Because of the comments I will try to elaborate more. I am using a canvas to plot out functions that a user inputs. The user will also be able to draw on the graph and I would like to store the line data of the drawing as well both I figured could be stored the same way and the computation of the points only needs to happen once.
A sample seniro would be a user can plot y=x^2 and then circle the y-intercept. Then they could link to that canvas and it would redraw their circle of the y-intercept and the graph. Of course this is simplistic example but I cannot figure out how to store the points on the canvas best.
Hope this helps more.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这称为一对多关系。你有一种形状和许多实际的点。您通常希望将点放入单独的表中,如下所示。
要创建新形状,请将新形状插入到
Shape
表中。然后在Point_Values
表中创建一个或多个值。当您想返回并获取值时,您可以使用联接,如下所示:这样做的优点是非常灵活。每个形状可以有 0 个或多个点,并且隐式强制要求 x 和 y 点的数量必须相等。
This is called a one-to-many relationship. You have one shape and many actual points. You would usually want to put the points into a separate table, like this.
To make a new shape, insert a new shape into the
Shape
table. Then create one or more values in thePoint_Values
table. When you want to go back and get the values, you would use a join, like this:This has the advantage of being very flexible. Each shape can have 0 or more points, and there is an implicit enforcement that there must be an equal number of x and y points.