Hi All,
Short question: How can I create constrains (like primary key and foreign key) amongst enterprise database tables?
Detailed description: I know that for file based geodatabase, to achieve constraints or relationships there are RelationshipObjects. But in my case I am using Postgres database for nonspatial tables. Now I want to create primary-foreign key relatioship amongst them. How can I do that?
I am using below code which works for file based database but not for the Enterprise databases.
ADJUSTIT_DB_CONN = "C:/Users/jbheda.WE-DO-IT/Documents/ArcGIS/Projects/MyProject4/localhost.sde"
config = os.path.join(ADJUSTIT_DB_CONN,"config")
network = os.path.join(ADJUSTIT_DB_CONN,"network")
configNetworkRelClass = os.path.join(ADJUSTIT_DB_CONN,"configNetworkRel")
configLandbaseRelClass = os.path.join(ADJUSTIT_DB_CONN,"configLandbaseRel")
env.overwriteOutput = True
######### FUNCTIONS ###########
config_table = arcpy.CreateTable_management(os.path.dirname(config), os.path.basename(config))
arcpy.AddField_management(config_table, "config_name", "TEXT", field_length=256)
arcpy.AddField_management(config_table, "user_updated", "TEXT", field_length=64)
network_table = arcpy.CreateTable_management(os.path.dirname(network), os.path.basename(network))
arcpy.AddField_management(network_table, "table_name", "TEXT", field_length=256)
arcpy.AddField_management(network_table, "config_name", "TEXT", field_length=256)
# Create simple relationship class between 'config' and 'network'
forLabel = "network_list"
backLabel = "network_config_name"
primaryKey = "config_name"
foreignKey = "config_name"
arcpy.CreateRelationshipClass_management(config, network, configNetworkRelClass, "SIMPLE", forLabel, backLabel, "NONE", "ONE_TO_MANY", "NONE", primaryKey, foreignKey)
Since you are using Arcpy, the question is more suited in the Python API community. So, also try asking there.