3

I've noticed that it is possible (at least in ArcGIS 10.1) having within a Personal geodatabase, a relationship class and a feature class/table with the same name!. This is my example:

enter image description here

The above example was created by using ArcCatalog manually, but now I want to do some scripting in Python.

The problem I'm having is that after using arcpy.Describe(path_to_dataset).children, in which I can easily list the existing relationship classes by using datatype == "RelationshipClass". Then, I'm unable to access the rc individually on this way:

arcpy.Describe(path_to_rs) because ArcGIS picks up by default the fc always, not the rc, and both have the same path.

Any ideas?

  • 2
    Are you able to provide a code snippet that illustrates how you are able to make a feature class and relationship class with the same name in the same file geodatabase? – PolyGeo Jun 12 '17 at 13:04
  • 1
    @PolyGeo Not sure about file geodatabases, but I was just reading this documentation today (coincidentally) stating that for SDE databases, the NAME values in the GDB_ITEMS table are not guaranteed to be unique and even calls out to a relationship class and a feature class having the same name. desktop.arcgis.com/en/arcmap/10.3/manage-data/… – Richard Morgan Jun 12 '17 at 18:43
10
+100

If you've worked with the Copy tool in the past, you may have noticed a "Data type" parameter. This supports distinguishing between two data types with the same name.

This is also possible with Describe, although in a non-obvious, hidden way. If you use arcpy.gp.Describe, you can specify a second argument that does the same thing as Copy's, allowing you to hone in on the datatype you actually want.

my_data = "<some path>"

describe_rc = arcpy.gp.Describe(my_data, 'RelationshipClass')
print(describe_rc.datatype)

describe_fc = arcpy.gp.Describe(my_data, 'FeatureClass')
print(describe_fc.datatype)
3

You are quite correct, it is possible to have Geodatabase objects with the same name. It's not limited to just Personal Geodatabase but also File and Enterprise GDB.

It does appear that creating a Relationship Class from ArcCatalog (right-click > New > Relationship Class) will allow you to create one with the same name as a Feature Class. Alternatively you could rename your Feature Class to something else instead.

enter image description here

You could rename your Relationship Class to something else that doesn't exist, so you could rename yours from areas_km2 to areas_km2_rel. Then your arcpy will see them as different objects.

enter image description here

Interestingly, ArcCatalog will not let you rename an existing relationship class to a name that already exists - e.g. You can't rename areas_km2_rel to be areas_km2.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.