X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F93DDA662 for ; Mon, 21 Nov 2005 19:59:18 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98202-05 for ; Mon, 21 Nov 2005 23:59:19 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from challengelogistics.com.au (unknown [203.48.241.83]) by svr1.postgresql.org (Postfix) with ESMTP id A11FCDA55B for ; Mon, 21 Nov 2005 19:59:13 -0400 (AST) Received: from isis.challengelogistics.com.au ([192.168.160.31]) by sameagle with InterScan Messaging Security Suite; Tue, 22 Nov 2005 10:59:19 +1100 Received: from sandy01.challengelogistics.com.au ([192.168.160.3]) by isis.challengelogistics.com.au with Microsoft SMTPSVC(6.0.3790.1830); Tue, 22 Nov 2005 11:01:30 +1100 From: "Bath, David" Reply-To: dave.bath@unix.net To: pgsql-sql@postgresql.org Subject: Re: idea for a geographically distributed database: how best to implement? Date: Tue, 22 Nov 2005 11:02:47 +1100 User-Agent: KMail/1.8 References: In-Reply-To: Cc: andy@areyoulocal.co.uk MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511221102.49528.dave.bath@unix.net> X-OriginalArrivalTime: 22 Nov 2005 00:01:30.0406 (UTC) FILETIME=[E4461C60:01C5EEF7] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/182 X-Sequence-Number: 23433 On Thu, 17 Nov 2005 19:44, Andy Ballingall wrote: > I've got a database for a website which is a variant of the 'show stuff near > to me' sort of thing. > > Rather than host this database on a single server, I have a scheme in mind > to break the database up geographically so that each one can run comfortably > on a small server, but I'm not sure about the best way of implementing it. There are a couple of philosophical perspectives I've come across in previous work with cadastral data that may be useful. 1) A given point may be in more than one "hierarchy" of geographical units (ofbiz.org implements this quite well with different region types and a "region relationship type" table). 2) Some relevant hierarchies involve irregular shapes. e.g. a) postal/zip codes are not squares e.g. b) Often a postal/zip code system for a country is only loosely based on states/province, as sometimes "twin cities" can straddle a river and state/province boundary, but the postal centre for both sides is handled from one side. (The same often applies for business servicing). An example that comes to mind is Mildura (Victoria/Australia) and its smaller sibling across the Murray River, Wentworth (New South Wales/Australia). e.g. c) the "capture" area for many offices are often based on the state/province, again, not square. 3) There are ways of looking at "approximate nearness" of irregular shapes (although the same applies to squares) using terms such as "centric" and "centroid", which involve things like drawing the smallest circle AROUND a region that encloses ALL of it, or the largest circle INSIDE a region. It might be relevant to consider the "slightly outside but close" points in your "replication" as well. (In my previous example, Mildura and Wentworth would be included in the databases of branch offices in BOTH Vic and NSW, although one office should be considered authoritative, as services for both might be through Victorian branch offices, although Wentworth customers are likely to contact the NSW branch office). It is useful to consider "extending" the diameter of the circle enclosing the entire region by x%. Yep, "squaring the circle" and "circling the square" are useful in the real world. 4) There are a lot of useful bits and pieces at opengis.org and postgis.org 5) There are many useful GIS functions in postgres to decide if a point is inside an irregular polygon (including whether it has both convex and concave bits), and whether any two shapes overlap. Hope these points are useful. -- David T. Bath dave.bath@unix.net