[GIS] Importing/copying geodatabase schema from multiple tables to single table

arccatalogarcgis-desktopdatabase-designesri-geodatabase

I have an existing ArcGIS 10 geodatabase which has a complicated schema containing multiple tables and joins, and I wish to simplify this for faster web delivery.

For example, Featureclass1 is related to Table1, Table2, TableN, and I wish to copy or import the attributes from each Table onto Featureclass1. This will result in a single Featureclass containing all attributes.

What is the fastest way to do this in a repeatable manner (ie, without doing it manually in ArcCatalog)?

This is what I'm considering:

  • When creating a new featureclass or table in ArcCatalog, there is the option to Import the schema from an existing table/FC. However, this only allows you to import from Table1 (if you then choose Table2, it drops the fields from Table1).

  • The Geodatabase Diagrammer is a great tool for reporting on an existing schema, and designing a new one – but I can't see any options to import multiple fields simply (it seems to require manual entry of each new field).

  • writing a Python script to do it iteratively. Is this the best option?

Note that I'm only concerned with the schema at this stage, not the actual data import.

Best Answer

I would personally use arcpy.MakeQueryTable_management and then use that table to create a new featureclass with that as its template.

Please note, that the layer that is created by the tool is temporary and will not persist; you have to use the item created by this, in creating a permanent table

Alternatively, you could just code the creation of the table using arcpy.CreateTable_management, with something like this:

arcpy.CreateTable_management(InputWorkspace,TabName,"",VectorConfigKeyword)

# Process: Add Field
for field in [TabField1,TabField2,TabField3,TabField4,TabField5]:
    arcpy.AddField_management(InputWorkspace + "\\" + TabName, field[0], field[1], field[2],field[3], field[4], field[5], field[6], field[7], field[8])

arcpy.AddIndex_management(InputWorkspace + "\\" + TabName,IndexParams[0],IndexParams[1],IndexParams[2],IndexParams[3])

TabField1 = ["ID","LONG","","","","","NON_NULLABLE","REQUIRED",""]
TabField2 = ["Name","TEXT","","","255","","NON_NULLABLE","REQUIRED",""]
etc
IndexParams = ["ID",TabName + "_RID_IDX","UNIQUE","ASCENDING"]

That way you can design and build your FC anytime you like.

Related Question