如何将 MySQL 空间数据类型与多边形的链接数据结合使用?

发布于 2024-12-31 23:45:08 字数 141 浏览 2 评论 0原文

我将有一个包含很多点的表(声明为 POINT)。现在我想用一些多边形和类似的东西创建另一个表。多边形应链接到第一个表的点;如果我更改第一个表中的一个点,第二个表中的多边形应该自动更新 - 它们应该被链接。

这可能吗?或者我应该为自己复制数据并创建冗余?

I will have a table with a lot of points (declared as POINT). Now I want to create another table with some polygons and similar. The polygons should be linked to the points of the first table; if I change one point in the first table, the polygons in the second table should updated automatically - they should be linked.

Is this possible? Or should I copy the data for myself and create the redundancy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚雾 2025-01-07 23:45:08

为点创建主键,并从多边形表中引用该列(外键引用)。当您查询多边形时,您将连接两个表。

编辑

以前的解决方案是错误的,如果您从点表中引用多边形 id,则它是正确的:

Points (id, coordx, coordy, polygon_id, ...)
Polygons (id, ...)

Create a primary key for the points, and reference this column from the polygon table (foreign key reference). When you query the polygons you join the two tables.

EDIT

Previous solution is wrong, it's correct if you reference polygon id from points table like this:

Points (id, coordx, coordy, polygon_id, ...)
Polygons (id, ...)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文