This page last changed on Oct 30, 2007 by jdeolive.

This page contains some design and brainstorming about the partial support of XLink for WFS 1.1.

Requirements

We can limit some scope to make things a bit simpler:

  • limit to local references
  • limit to geometries and features
  • support only through relational database foreign keys

Modeling Associations

A natural way to model an association is with foreign keys in a database. Determining

Consider the following example of a simple table representing the flag of a country:

flag
fid integer primary key
location point  
height double  

This maps straight across to a feature type:

  "featureType": {
    "name": "flag",
    "attributes": {
       "attribute": [
          { "name": "location", "type": "Point" },
          { "name": "height", "type": "Double" }
       ]
    }
  }

Now consider the following table representing the country itself:

country
fid integer primary key
geometry polygon  
name varchar  
  "featureType": {
    "name": "country",
    "attributes": {
       "attribute": [
          { "name": "geometry", "type": "Polygon" },
          { "name": "name", "type": "String" }
       ]
    }
  }

Now consider the following association from flag to country:

flag
fid integer primary key
location point  
height double  
country integer foreign key

Where the country column is a foreign key link to the fid column of the country table. This is where things get interesting. The question is how to model this relationship in a feature type. There are two alternatives:

1. Association

In the geoapi feature model ( geotools feature model 2 ), feature types may contain "associations" explicitly. This would result in the following feature type:

  "featureType": {
    "name": "flag",
    "attributes": {
       "attribute": [
          { "name": "location", "type": "Point" },
          { "name": "height", "type": "Double" }
       ]
    }, 
    "associations": {
       "association": [
          { 
            "name": "country",
            "relatedType": "featureType": {
                "name": "country",
                "attributes": {
                    ...
                }
            } 

          }
       ]
    }
  }

2. Attribute

One of the problems with the previous approach is that it requires use of the complex version of the feature model, as associations fall out of the realm of "simple features". Unfortunately this ups the level of effort required to pull it off. So an alternative is just to model with an attribute:

  "featureType": {
    "name": "flag",
    "attributes": {
       "attribute": [
          { "name": "location", "type": "Point" },
          { "name": "height", "type": "Double" },
          { "name": "country", "type": "Feature" }
       ]
    } 
  }
Document generated by Confluence on May 14, 2014 23:00