简体   繁体   English

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

[英]How can I use MySQL spatial datatypes with linked data for polygons?

I will have a table with a lot of points (declared as POINT). 我将有一个包含很多要点的表(声明为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? 还是我应该为自己复制数据并创建冗余?

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: 先前的解决方案是错误的,如果您从点表中引用多边形ID像这样是正确的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM