Romain
Romain

Reputation: 3758

Having a generic GEOGRAPHY column with PostGIS

In PostgreSQL 9 + PostGIS 1.5, is there a way to create a "generic" GEOGRAPHY column? By that I mean a column that would accept POINTs as well as POLYGONs, LINESTRINGs, etc. Until now, I've only seen columns like GEOGRAPHY(POINT,4326) on the Internet.

If that is not possible, then how would you design (from a DB point of view) an entity that is linked to a random geographical object (point, polygon, whatever)? Should I create 3, 4, 5 different tables for each type of geographical object I'd like to support? (1 table for POINT objets, 1 table for POLYGON objects and so on)?

Thanks in advance.

Romain

Upvotes: 4

Views: 2471

Answers (1)

Paul Ramsey
Paul Ramsey

Reputation: 841

Yes, just don't specify a type constraint in the CREATE TABLE statement.

CREATE TABLE mytable ( geog GEOGRAPHY, id SERIAL PRIMARY KEY );

Upvotes: 10

Related Questions