Decomposing Spatial Databases with Applications