Query processing and data allocation in distributed database systems