Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to be able to detect relationship classes in a file GDB. Because users of my script might have only an ArcView level license, they would not be able to manipulate the schema of a feature class (specifically to add a field) that is in a workspace that has relationship classes. How do I detect the presence of relationship classes, so that I can document them, avoid them programatically, and allow the script to continue?

share|improve this question

The relationshipClassNames property is supposed to do this but it does not seem to work for me (tested in a file geodatabase, created relationship class between two feature classes, checked the property, the list returned is empty for both). Maybe it will work for you.

share|improve this answer
Thanks. I was missing how to get to relationship classes in the first place, but you gave me the clue. I shall check out the relationshipClassNames property and let you know how it works (or doesn't). – celticflute Nov 1 '11 at 4:28

Per @blah238 suggustion, This python code lists all Relashionship classes within a geodatabase and put them in a unique list (relClasses):

inGDB = r"D:\mygeodatabase.gdb"
env.workspace = inGDB
#################Getting all Tables and Feature Classes###########
fcs = []
#root of workspace
for item in arcpy.ListFeatureClasses("*"):    fcs.append(item)
for item in arcpy.ListTables("*"):    fcs.append(item)

fds = arcpy.ListDatasets("*","Feature")
for fd in fds:
    env.workspace = inGDB +'\\'+fd
    for fc in arcpy.ListFeatureClasses("*"):
    for tb in arcpy.ListTables("*"):

env.workspace = inGDB
relClasses = set()
for i,fc in enumerate(fcs): 
    desc = arcpy.Describe(fc)
    for j,rel in enumerate(desc.relationshipClassNames):
        relDesc = arcpy.Describe(rel)
        if relDesc.isAttachmentRelationship:

print relClasses
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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