Represents either a permanent geodatabase relationship class or an in-memory relationship between two tables.

Namespace:  ESRI.ArcGISExplorer.Data

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public sealed class TableRelationship : IDisposable
Visual Basic (Declaration)
Public NotInheritable Class TableRelationship _
	Implements IDisposable

Remarks

The following is a summary of the key points for working with the TableRelationship class:

  • Geodatabase relationship classes cannot be created. Use the CreateMemoryRelationship method to create an in-memory relationship between two tables where the cardinality is either one-to-one (1:1) or one-to-many (1:N). In-memory relationships cannot be created if the cardinality is many-to-many (M:N) and additionally they cannot be attributed.
  • Currently it is not possible to access the additional attribute information stored in the geodatabase-managed, linking table used in an attributed relationship.
  • For non-attributed, one-to-one or one-to-many relationships there is a direct link between the two tables. The OriginKeyColumnName in the OriginTable and the OriginForeignKeyColumnName in the DestinationTable describes the linkage.
  • For attributed, one-to-one or one-to-many relationships and all many-to-many relationships there is an indirect link between the two tables. A third table, which conceptually sits between the two tables, links them together. The OriginKeyColumnName in the OriginTable is linked to the OriginForeignKeyColumnName in the third table and the DestinationKeyColumnName in the DestinationTable is linked to the DestinationForeignKeyColumnName in the third table.

Examples

The code below accesses two geodatabase relationship classes and prints out the properties stored in the corresponding TableRelationship objects.
CopyC#
//Example 1 - Open a geodatabase relationship class which has a one-to-many cardinality 
//and print out the TableRelationship properties.

//Open file geodatabase
Geodatabase scotlandGdb = new Geodatabase(@"C:\Data\Scotland.gdb");

//Open the mountains feature class
Table mountains = scotlandGdb.OpenTable("mountains");

//Open the MountainRatings geodatabase relationship class
TableRelationship mtnAndRatingsRel = scotlandGdb.OpenTableRelationship("MountainRatings");

//Print out properties describing the TableRelationship 
System.Diagnostics.Debug.Print(mtnAndRatingsRel.Name);                        //Prints "MountainRatings"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.Type.ToString());             //Prints "Geodatabase"          
System.Diagnostics.Debug.Print(mtnAndRatingsRel.Cardinality.ToString());      //Prints "OneToMany"   
System.Diagnostics.Debug.Print(mtnAndRatingsRel.IsAttributed.ToString());     //Prints "False"  
System.Diagnostics.Debug.Print(mtnAndRatingsRel.OriginTable.Name);            //Prints "mountains"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.OriginKeyColumnName);         //Prints "OBJECTID"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.DestinationTable.Name);       //Prints "mtn_ratings"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.OriginForeignKeyColumnName);  //Prints "MTN_ID"

//Example 2 - Open a geodatabase relationship class which has a many-to-many cardinality 
//and print out the TableRelationship properties.

//Open file geodatabase
Geodatabase propertiesGdb = new Geodatabase(@"C:\Data\Property.gdb");

//Open the Properties feature class
Table properties = propertiesGdb.OpenTable("Properties");

//Open the PropertyOwners geodatabase relationship class
TableRelationship propertyOwnersRel = propertiesGdb.OpenTableRelationship("PropertyOwners");

//Print out properties describing the TableRelationship 
System.Diagnostics.Debug.Print(propertyOwnersRel.Name);                           //Prints "PropertyOwners"
System.Diagnostics.Debug.Print(propertyOwnersRel.Type.ToString());                //Prints "Geodatabase"          
System.Diagnostics.Debug.Print(propertyOwnersRel.Cardinality.ToString());         //Prints "ManyToMany"   
System.Diagnostics.Debug.Print(propertyOwnersRel.IsAttributed.ToString());        //Prints "False"  
System.Diagnostics.Debug.Print(propertyOwnersRel.OriginTable.Name);               //Prints "Properties"
System.Diagnostics.Debug.Print(propertyOwnersRel.OriginKeyColumnName);            //Prints "PropertyID"
//Note that the OriginForeignKeyColumnName is in a geodatabase-managed "link" table
System.Diagnostics.Debug.Print(propertyOwnersRel.OriginForeignKeyColumnName);     //Prints "PropID"
System.Diagnostics.Debug.Print(propertyOwnersRel.DestinationTable.Name);          //Prints "Owners"
System.Diagnostics.Debug.Print(propertyOwnersRel.DestinationKeyColumnName);       //Prints "OwnerID"
//Note that the DestinationForeignKeyColumnName is a geodatabase-managed "link" table
System.Diagnostics.Debug.Print(propertyOwnersRel.DestinationForeignKeyColumnName);//Prints "OwnID"
CopyVB.NET
'Example 1 - Open a geodatabase relationship class which has a one-to-many cardinality 
'and print out the TableRelationship properties.


'Open file geodatabase
Dim scotlandGdb As Geodatabase = New Geodatabase("C:\Data\Scotland.gdb")

'Open the mountains feature class
Dim mountains As Table = scotlandGdb.OpenTable("mountains")

'Open the MountainRatings geodatabase relationship class
Dim mtnAndRatingsRel As TableRelationship = scotlandGdb.OpenTableRelationship("MountainRatings")

'Print out properties describing the TableRelationship 
System.Diagnostics.Debug.Print(mtnAndRatingsRel.Name)                        'Prints "MountainRatings"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.Type.ToString())             'Prints "Geodatabase"          
System.Diagnostics.Debug.Print(mtnAndRatingsRel.Cardinality.ToString())      'Prints "OneToMany"   
System.Diagnostics.Debug.Print(mtnAndRatingsRel.IsAttributed.ToString())     'Prints "False"  
      System.Diagnostics.Debug.Print(mtnAndRatingsRel.OriginTable.Name)            'Prints "mountains"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.OriginKeyColumnName)         'Prints "OBJECTID"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.DestinationTable.Name)       'Prints "mtn_ratings"
System.Diagnostics.Debug.Print(mtnAndRatingsRel.OriginForeignKeyColumnName)  'Prints "MTN_ID"


'Example 2 - Open a geodatabase relationship class which has a many-to-many cardinality 
'and print out the TableRelationship properties.


'Open file geodatabase
Dim propertiesGdb As Geodatabase = New Geodatabase("C:\Data\Property.gdb")

'Open the Properties feature class
Dim properties As Table = propertiesGdb.OpenTable("Properties")

'Open the PropertyOwners geodatabase relationship class
Dim propertyOwnersRel As TableRelationship = propertiesGdb.OpenTableRelationship("PropertyOwners")

'Print out properties describing the TableRelationship 
System.Diagnostics.Debug.Print(propertyOwnersRel.Name)                           'Prints "PropertyOwners"
System.Diagnostics.Debug.Print(propertyOwnersRel.Type.ToString())                'Prints "Geodatabase"          
System.Diagnostics.Debug.Print(propertyOwnersRel.Cardinality.ToString())         'Prints "ManyToMany"   
System.Diagnostics.Debug.Print(propertyOwnersRel.IsAttributed.ToString())        'Prints "False"  
System.Diagnostics.Debug.Print(propertyOwnersRel.OriginTable.Name)               'Prints "Properties"
System.Diagnostics.Debug.Print(propertyOwnersRel.OriginKeyColumnName)            'Prints "PropertyID"
'Note that the OriginForeignKeyColumnName is in a geodatabase-managed "link" table
System.Diagnostics.Debug.Print(propertyOwnersRel.OriginForeignKeyColumnName)     'Prints "PropID"
System.Diagnostics.Debug.Print(propertyOwnersRel.DestinationTable.Name)          'Prints "Owners"
System.Diagnostics.Debug.Print(propertyOwnersRel.DestinationKeyColumnName)       'Prints "OwnerID"
'Note that the DestinationForeignKeyColumnName is a geodatabase-managed "link" table
System.Diagnostics.Debug.Print(propertyOwnersRel.DestinationForeignKeyColumnName) 'Prints "OwnID"

Inheritance Hierarchy

System..::.Object

  ESRI.ArcGISExplorer.Data..::.TableRelationship

See Also