<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Robert,</div><div><br></div>You can get as complex as you like, but one great use of schemas (I think) has been to manage backing up data - especially over the internet, another is to manage user access at a more granular level.<div><br></div><div>if you put your static data (ie background maps) into one schema, then when dumping you can use the -N flag to avoid dumping that schema. By doing this we avoid backing up several hundred megabytes every night, but new research location data is backed up daily - only a few megabytes</div><div><br></div><div>similarly, for some projects you might have data on users and access controls, but when analysing the data this isn't necessary, so putting important (perhaps research) data into it's own schema makes it easy to export from a database server to a local machine for analysis.</div><div><br></div><div>Dont forget to </div><div><br></div><div>ALTER DATABASE mydatabase SET search_path TO mymainschema, myotherschema, someotherstuff, public;</div><div><br></div><div>cheers</div><div><br></div><div>Ben</div><div><br></div><div><br></div><div><div><div>On 22/09/2011, at 6:17 PM, Robert Buckley wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">I have just read this explaining about how to structure data and functions within postgresql</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><a href="http://blog.cleverelephant.ca/2010/09/postgis-back-up-restore.html">http://blog.cleverelephant.ca/2010/09/postgis-back-up-restore.html</a><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><span class="Apple-tab-span" style="white-space:pre"> </span>..."<span class="Apple-style-span" style="color: rgb(48, 48, 48); font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 17px; ">The "public" schema is where the PostGIS functions and system tables get
installed, so if you dump that schema you get all those definitions in your dump. If those definitions are mixed in amongst your data, loading them into a fresh database gets tricky: are the paths to the libraries the same? are there function name clashes? (The utils/postgis_restore.pl script attempts manfully to strip out PostGIS components from a dump file to allow a clean restore, but it is hard to get 100% performance.)</span></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><span class="Apple-style-span" style="color: rgb(48, 48, 48); font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 17px; "><span class="Apple-tab-span" style="white-space:pre"> </span></span><span class="Apple-style-span" style="color: rgb(48, 48, 48); font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 17px; ">If, on the other hand, all your data is neatly separated into its own schema, you can
neatly backup <em style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">just that schema</em> and avoid having PostGIS system information mixed in with your data. That means you can easily restore your data into <em style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">any version of PostGIS and PostgreSQL that you like</em>. So upgrades are easy easy easy.</span></div><span class="Apple-style-span" style="color: rgb(48, 48, 48); font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 17px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong style="margin-top: 0px; margin-right: 0px;
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Remember: Store your data in a schema other than "public".</strong></span><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><span class="Apple-style-span" style="color: rgb(48, 48, 48); font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 17px; ">"</span></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Basically Paul recommends saving geodata in a different schema to the postgis functions. </div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">My questions are...</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><span class="Apple-tab-span" style="white-space:pre"> </span></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">1<span class="Apple-tab-span" style="white-space:pre"> </span>"if the data is located in a different schema which does not have the 800 odd postgis functions, are the functions still available to the data?"</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">2<span class="Apple-tab-span" style="white-space:pre"> </span>"are cross schema queries allowed?"</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">3 <span class="Apple-tab-span" style="white-space:pre"> </span>"does it also make sense to seperate non-spatial tables into their own schemas?"</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif;
font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">thanks for any advice,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Rob</div></div></div>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>http://postgis.refractions.net/mailman/listinfo/postgis-users<br></blockquote></div><br></div></body></html>