How to relate a Spatial and Non Spatial table in PostGIS to be visualized in QGIS

المشرف العام

Administrator
طاقم الإدارة
first of all I'm quiet new in PostGIS.

I'm working in pgadminIII with postGIS. I have in one database two tables. See the two tables SQL Pane.

CREATE TABLE gw_body_characterisation2 ( gwb_code_e character varying(64), gwb_code_w character varying(64), gwname character varying(254) NOT NULL, reference_ smallint, gwno_of_ho smallint, national_c character varying(50), rbdcode character varying(50), rbdname character varying(254), gwarea double precision, remarks character varying(254), CONSTRAINT gw_body_characterisation2_pkey PRIMARY KEY (gwname) ) WITH ( OIDS=FALSE ); ALTER TABLE gw_body_characterisation2 OWNER TO postgres; The other table is

CREATE TABLE boundaries ( gwname character varying(254), coord_x numeric, coord_y numeric, shape_leng numeric, shape_area numeric, geom geometry(MultiPolygon), CONSTRAINT boundaries_gwname_fkey FOREIGN KEY (gwname) REFERENCES gw_body_characterisation2 (gwname) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH ( OIDS=FALSE ); ALTER TABLE boundaries OWNER TO postgres; The table called boundaries contains polygons representing aquifers,and the table 'gw_body_characterisation2' contains some information about the aquifer. Attempting to create a relation between the two tables I have set as PRIMARY KEY the field called gwname in the table gw_body_characterisation2 and as FOREIGN KEY in the tables. I have done this visually by following a tutorial

gwname is the common attribute between the two tables

Once having done that, I connected QGIS to my postGIS database. However both tables seem to be no related.


I've done some research, and this the polygons can be related to the non spatial info in QGIS. However, I want this to be done in Pgadmin, and the relation still valid in Quantum GIS when visualizing the polygons.

I believe that there is an SQL statement, or a visual way to create this relation. Moreover, the relation should be one to one. I know that, when there is one to one relations, it's easy to join the tables, but I want the spatial info in one separate table.

If there is a visual way to do it in pgadmin III, please let me know. If there is an SQL statement to relate tables let me know to considering that I'm new into SQL/Pgadmin world.

Thanks for your help in advance. P.s.I have dome some research on the web, and I have gained some insights but nothing has actually adressed the issue. At least, to my knowledge.



أكثر...
 
أعلى