<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Arcpy: Create Enterprise database tables with constraints in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-create-enterprise-database-tables-with/m-p/833260#M3260</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Short question: How can I create constrains (like primary key and foreign key) amongst enterprise database tables?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using below code which works for file based database but not for the Enterprise databases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ADJUSTIT_DB_CONN = "C:/Users/jbheda.WE-DO-IT/Documents/ArcGIS/Projects/MyProject4/localhost.sde"&lt;/P&gt;&lt;P&gt;config = os.path.join(ADJUSTIT_DB_CONN,"config")&lt;BR /&gt;network = os.path.join(ADJUSTIT_DB_CONN,"network")&lt;/P&gt;&lt;P&gt;configNetworkRelClass = os.path.join(ADJUSTIT_DB_CONN,"configNetworkRel")&lt;BR /&gt;configLandbaseRelClass = os.path.join(ADJUSTIT_DB_CONN,"configLandbaseRel")&lt;/P&gt;&lt;P&gt;env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;######### FUNCTIONS ###########&lt;BR /&gt; config_table = arcpy.CreateTable_management(os.path.dirname(config), os.path.basename(config))&lt;BR /&gt; arcpy.AddField_management(config_table, "config_name", "TEXT", field_length=256)&lt;BR /&gt; arcpy.AddField_management(config_table, "user_updated", "TEXT", field_length=64)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;network_table = arcpy.CreateTable_management(os.path.dirname(network), os.path.basename(network))&lt;BR /&gt; arcpy.AddField_management(network_table, "table_name", "TEXT", field_length=256)&lt;BR /&gt; arcpy.AddField_management(network_table, "config_name", "TEXT", field_length=256)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; # Create simple relationship class between 'config' and 'network'&lt;/P&gt;&lt;P&gt;forLabel = "network_list"&lt;BR /&gt; backLabel = "network_config_name"&lt;BR /&gt; primaryKey = "config_name"&lt;BR /&gt; foreignKey = "config_name"&lt;BR /&gt; arcpy.CreateRelationshipClass_management(config,&amp;nbsp;network,&amp;nbsp;configNetworkRelClass,&amp;nbsp;"SIMPLE",&amp;nbsp;forLabel,&amp;nbsp;backLabel,&amp;nbsp;"NONE",&amp;nbsp;"ONE_TO_MANY",&amp;nbsp;"NONE",&amp;nbsp;primaryKey,&amp;nbsp;foreignKey)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 May 2017 01:36:08 GMT</pubDate>
    <dc:creator>JadavBheda</dc:creator>
    <dc:date>2017-05-15T01:36:08Z</dc:date>
    <item>
      <title>Arcpy: Create Enterprise database tables with constraints</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-create-enterprise-database-tables-with/m-p/833260#M3260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Short question: How can I create constrains (like primary key and foreign key) amongst enterprise database tables?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using below code which works for file based database but not for the Enterprise databases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ADJUSTIT_DB_CONN = "C:/Users/jbheda.WE-DO-IT/Documents/ArcGIS/Projects/MyProject4/localhost.sde"&lt;/P&gt;&lt;P&gt;config = os.path.join(ADJUSTIT_DB_CONN,"config")&lt;BR /&gt;network = os.path.join(ADJUSTIT_DB_CONN,"network")&lt;/P&gt;&lt;P&gt;configNetworkRelClass = os.path.join(ADJUSTIT_DB_CONN,"configNetworkRel")&lt;BR /&gt;configLandbaseRelClass = os.path.join(ADJUSTIT_DB_CONN,"configLandbaseRel")&lt;/P&gt;&lt;P&gt;env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;######### FUNCTIONS ###########&lt;BR /&gt; config_table = arcpy.CreateTable_management(os.path.dirname(config), os.path.basename(config))&lt;BR /&gt; arcpy.AddField_management(config_table, "config_name", "TEXT", field_length=256)&lt;BR /&gt; arcpy.AddField_management(config_table, "user_updated", "TEXT", field_length=64)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;network_table = arcpy.CreateTable_management(os.path.dirname(network), os.path.basename(network))&lt;BR /&gt; arcpy.AddField_management(network_table, "table_name", "TEXT", field_length=256)&lt;BR /&gt; arcpy.AddField_management(network_table, "config_name", "TEXT", field_length=256)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; # Create simple relationship class between 'config' and 'network'&lt;/P&gt;&lt;P&gt;forLabel = "network_list"&lt;BR /&gt; backLabel = "network_config_name"&lt;BR /&gt; primaryKey = "config_name"&lt;BR /&gt; foreignKey = "config_name"&lt;BR /&gt; arcpy.CreateRelationshipClass_management(config,&amp;nbsp;network,&amp;nbsp;configNetworkRelClass,&amp;nbsp;"SIMPLE",&amp;nbsp;forLabel,&amp;nbsp;backLabel,&amp;nbsp;"NONE",&amp;nbsp;"ONE_TO_MANY",&amp;nbsp;"NONE",&amp;nbsp;primaryKey,&amp;nbsp;foreignKey)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 May 2017 01:36:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-create-enterprise-database-tables-with/m-p/833260#M3260</guid>
      <dc:creator>JadavBheda</dc:creator>
      <dc:date>2017-05-15T01:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy: Create Enterprise database tables with constraints</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-create-enterprise-database-tables-with/m-p/833261#M3261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you are using Arcpy, the question is more suited in the&amp;nbsp;&lt;A _jive_internal="true" href="https://community.esri.com/community/developers/gis-developers/python"&gt;Python API&lt;/A&gt; community. So, also try asking there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 May 2017 19:18:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-create-enterprise-database-tables-with/m-p/833261#M3261</guid>
      <dc:creator>KaushikMysorekar</dc:creator>
      <dc:date>2017-05-15T19:18:44Z</dc:date>
    </item>
  </channel>
</rss>

