I'm pretty new to spatial stuff so forgive the beginner question. If I expect to have many polygons that look like the picture, is it best to have 1 table with a column defined like
POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30),(20 30, 35 35, 30 20, 20 30),(20 30, 35 35, 30 20, 20 30),(20 30, 35 35, 30 20, 20 30))
or Two tables, one which has the outside polygons and one which has the inside polygons and the id of the containing polygon from the first table?
My use case will often be queries asking "Is this point in the outer polygon?" and "Which polygon(s) contain this point?". For the latter, I would like to only return the inner-most polygon if possible.
So for my first case (1 table) I'm thinking sudo code would look something like.
len = SELECT NumInteriorRings(g1)
and then loop through each interior polygon using something like
for(i = 1; i < len; ++i){
SELECT ST_CONTAINS(InteriorRingN(poly,i),point)
}
My Second case (2 tables) would look more like
SELECT sub_poly_id, ST_CONTAINS(poly, point) as contains
FROM sub_poly_table WHERE parent_poly_id = 23;
The second case seems more clean but am I just butchering my first case? Is there a better way to accomplish this?