How To: Create a many-to-many relationship in a geodatabase
Instructions provided describe an example of how to create a many-to-many relationship class in ArcGIS.
Additional information on relationship classes can be found in the book 'Modeling Our World', Chapter 3, in the section entitled 'Vector modeling with features', p. 78-85.
Another resource is Desktop Help, installed with ArcGIS, and also available online. In the Table of Contents, navigate to the section Professional Library > Data Management > Geographic data types > Relationships and related objects.
The following is an example of creating a many-to-many relationship between a parcel feature class and a table of parcel owners.
- In ArcCatalog, create a new file or personal geodatabase.
- Create a new polygon feature class in the geodatabase called Parcels. Add a column called Pin, which is a key field for this feature class.
- Create a new stand-alone table in the geodatabase called Owners. Add a column called Owner_Id which is the key field for this table.
- Create the relationship class between the Parcels feature class and the Owners table. The following image lists the parameters to be used, and shows how the final summary dialog should appear.
- Start ArcMap and add the Parcels, Owners, and ParcelToOwners datasets to the display.
- Start an edit session and add several polygon features to Parcels and add several records to the Owners table. Make sure to populate the key fields in Parcels (Pin) and Owners (Owner_Id). Save the edits.
Records cannot be added directly to the ParcelsToOwners table. The remaining steps explain the procedure for adding records to this intermediate table.
- Select one feature from Parcels and one record from the Owners table. Multiple selections can be made by holding down the Shift key while selecting.
- On the Editor toolbar, click the Attributes button to open the Attributes dialog box. Double-click the feature Object_Id number in the attributes dialog to see the 'is owned by' label.
- Right-click the 'is owned by' label and select Add Selected from the context menu.
Keep the Owners table open when editing so the Add Selected option is enabled.
- Open the ParcelsToOwners table. New records are added to the intermediate table containing the key values from the Parcels and Owners objects. Close this table after viewing the relationship.
- Select another feature from Parcels and several records from the Owners table. Repeat steps 8 through 10 to add several new records to the intermediate table.
When a stand-alone table listing the many-to-many relationships already exists, a tool in ArcToolbox can be used to automate the creation of the relationship table. The tool is found under Data Management Tools > Relationship Classes > Table To Relationship Class.
- ArcObjects SDK 10
- Desktop 10 Web Help
- Modeling Our World, Second Edition: The Esri Guide to Geodatabase Concepts
Last Published: 5/5/2016
Article ID: 000004999
Software: ArcMap 10.4.1, 10.4, 10.3.1, 10.3, 10.2.2, 10.2.1, 10.2, 10.1, 10