Decomposing Spatial Databases and Applications