A "FID" is a "Feature Identifier" as defined by the GML2 specification. (For GML3 they simply called this an "id" but the concept is still the same).
General Feature Model Identification
In the general feature model a feature it is actually supposed to identify the physical feature rather then just your data:
- so the same information from a shapefile and from PostGIS should have the same "id"
- the same object (say the Fraser River) should have the same "id" when represented in two tables in the same database
Geometry Markup Language Identification
Of course reality here differs in a couple of ways:
- in XML an "id" needs to be unique for a document
- in GML an "id" needs to start with a letter
To allow your data to work with GeoServer a datastore is responsible for generating an "id" that meets most of the above needs.
A DataStore will usually produce a FID:
- Starting with the FeatureType name (in order to start with a letter)
- Ending with some internal number
So for a shapefile "cities": "CITIES47" probably indicates the 47th feature in the shapefile.
When making use of a database:
- Use a primary key! (most databases will pick it up and produce "tablename"+"key"
- PostGIS will try and use the "oid" (object id) but this is unsuitable as it will change when you update)
Currently we let some datastore's get away with using FIDS (like oid above) that do not work well in transactions. This will let you get read access to you data, but to enable things like geoserver or uDig editing you may to double back and add primary keys for stable write access.