Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
AutoPLANT | OpenPlant | PlantWise
  • Product Communities
  • More
AutoPLANT | OpenPlant | PlantWise
AutoPLANT | OpenPlant | PlantWise Wiki Plant Project Database - Relationship Mapping
    • Sign in
    • -AutoPLANT | Bentley Raceway and Cable Management | OpenPlant | PlantWise Wiki
      • -OpenPlant
        • +CONNECT Services - OpenPlant
        • +Example Configuration - CONNECT Edition
        • +Installations - OpenPlant CONNECT Edition Applications
        • +OpenPlant Download Links & Videos
        • OpenPlant Product Compatibility
        • +OpenPlant Modeler CONNECT
        • +OpenPlant PID CONNECT
        • +OpenPlant Isometrics Manager CONNECT
        • +OpenPlant Orthographics Manager CONNECT
        • +OpenPlant Support Engineering CONNECT
        • +OpenPlant Project Administrator CONNECT
        • +OpenPlant CONNECT Edition-PlantSight Integration
        • +OpenPlant Modeler v8i
        • +OpenPlant Isometrics Manager v8i
        • +OpenPlant Project Administrator v8i
        • -OpenPlant PID v8i
          • +Application Solutions - OPPID
          • +Class Editor - OpenPlant PID
          • +Customization - OpenPlant PID
          • -Database - Plant Project
            • How to Create a new SQL Server Project and Synchronize OpenPlant PID Projects to it?
            • How do I turn on Number Auto Incrementation of Components on placement?
            • How to Associate an OpenPlant PID Drawing with Another Project
            • How to Change OPPID and Plant Project's Names
            • How to Configure Particular Project to Work in Offline Mode By Default
            • How to Create Custom Border and Map Custom Property with Database
            • How to Get Related Valve Tag in Instrument List in Data Manager
            • How to Map Custom Properties with Database
            • How to Map Input/Output Signal of Instrument in OpenPlant PID
            • How to Select Field Value from External Database PickList
            • How to Setup a Batch Routine to Sync all Drawings in my Project to the Database at one time
            • How To Show Modified Tag Format in Data Manager
            • How to Sync the Valve End Condition with Project DB
            • Importing Data into the Plant Project Database from an Excel Spreadsheet
            • Mapping Plant Project Extended Data Fields to OpenPlant PowerPID
            • OPPID - All drawings have same GUID. Drawings update database incorrectly
            • OPPID - Database Mapping Tips
            • OPPID - Document and their component Links
            • OPPID - Guidelines to ensure OPPID to APPID database field integrity
            • OPPID - How to determine Database Connection and Sync issues
            • OPPID - How To Get Motor Related to Equipment Sync to Database
            • OPPID - How to use the Class Editor Mapping Extension for the Plant Project Database
            • OPPID - Import of Associated Items
            • OPPID - YStrainer Database populate
            • OPPID Pipeline To-From SQL
            • OPPID- How to add custom properties to specific piece of equipment or sub class and link to a database
            • OPPID- SQL Logging
            • Plant Project Database - Class Mapping
            • Plant Project Database - Mappings
            • Plant Project Database - OpenPlant Validation and Repairing a Database Mapping
            • Plant Project Database - Operations with Schema Mapping and Mapping Add-in panel
            • +Plant Project Database - Oracle Install notes
            • Plant Project Database - Property Mapping
            • Plant Project Database - Relationship Mapping
            • Plant Project Database - Schema Mapping Custom Attributes
            • Plant Project Database Tag Format - Tag Codes
            • Setting OpenPlant PowerPID Project with Plant Database Project
            • SQL Server 2008 and Database to Schema Connection
            • To Import Modified Tags from Excel in Data Manager
            • Error: "Connection Test Failed" While Mapping SQL Database to Plant Project
            • Calculated EC Property Shows Failure Value in Data Manager
            • "{SERVICE_IS_RELATED_TO_EQUIPMENT(VG.0000003279)} belongs to the ECSchema {ECSchema: PlantProjectSchema.01.04} which is not supported in this connection" Error on Synchronizing from Database to Drawing
            • "Project ID 'XXXX' not found in AT_PROJ.DB3"
            • How to Move a Project Database from One Directory to Another For OPPID
            • Troubleshooting Synchronization issues using Component Selection Tool
          • +Properties - OpenPlant PID
          • +Release Notes - OpenPlant PID
          • +Training - OpenPlant PID
          • +White Papers/Guidelines - OPPID
        • +OpenPlant Orthographics Manager v8i
        • +OpenPlant Support Engineering v8i
        • +OpenPlant ModelServer v8i
        • +OpenPlant Reporting v8i
        • How to Connect with Bentley Technical Support Team using Microsoft Teams
        • How to Connect with Bentley Technical Support Team using Microsoft Teams via Browser
      • +Bentley AutoPLANT
      • +Bentley Navigator
      • +Bentley PlantSpace
      • +Plant Project Tools
      • +Bentley Raceway and Cable Management
      • i-model Composition Service for S3D
      • Working from home with OpenPlant
      • Working from home with Bentley Raceway and Cable Management
      • Working from home with AutoPLANT Modeler
    • How to Associate the Specification Based on Service in OpenPlant Modeler Connect

     
     Questions about this article, topic, or product? Click here. 

    Plant Project Database - Relationship Mapping

    In the EC object model a relationship class is a descendant of an ordinary class. It therefore has properties and can contain data. Hence an ECRelationship mapping is also a descendant of an ECClass mapping. Necessarily all operations previously described for the ECClass maping are possible for the relationship mapping too.

    Types of Relationships

    Natively a database maintains relationships via Foreign Keys. If the cardinality of relationship is defined 1 to many the Foreign Key is often a quite convenient way of storing such a relationships in a database.

    Another case of cardinality is many to many. These are mostly stored in a separate table or tables and sometimes have their own properties.

    Both types of relationships are supported by the Plant Project Database Mapping Extension.

    Mapping of Foreign Key relationships

    Let's take a look at a mapping of a Foreign Key relationship. For example select the "EQUIPMENT_HAS_NOZZLE" relationship in the relationship class tree and click the "Edit" button or right click on the relationship class and select "Add Mapping..." from the context menu. The Edit relationship Mapping dialog box is displayed. This dialog box is very similar to the Edit Class Mapping dialog box but has one additional section "Relationship" that contains mappings for Keys of the Source and Target related classes. To create a mapping of a Foreign Key relationship it is necessary to perform the following steps:

    • At first select the type of relationship in the "Storing Type" combo box. It is "FOREIGN_KEY" in our case.
    • After that it is necessary to provide the table where primary key value of the related object is contained in. For "EQUIPMENT_HAS_NOZZLE" the ID of EQUIPMENT is stored in the NOZZLE table:
      Add "NOZZLE" table.

    • After that it is necessary to define either the Source or the Target Key mapping.
      • If the ID of the Source relationship constraint class is in the table of the Target class then define the "Source Key"
      • If the ID of the Target relationship constraint class is in table of the Source class then define the "Target Key"

    In our example the Source constraint class is "EQUIPMENT" and the Target class is "NOZZLE". The ID of EQUIPMENT is in the Target's table. Thus it is necessary to define the "Source Key". Select "NOZZLE" as table and "NEQUIP" as column

    Note: Only one of the mappings either for the Source Key or for the Target Key should be provided for the Foreign Key relationship.

    Note: When a Foreign Key relationship mapping is created it is also optional possible to map ID, Name and Label and other properties similar to the Class Mapping. In practice such relationships are stored in a single field and even the InstanceID mapping cannot be provided. For such cases the InstanceID is auto-generated by the following rule:

    <Source Instance ID>.<Target Instance ID>.<ECClass Name>

    Note: The mapping of the Source Key and the Target Key allows involving two or more columns.

    Note: The value of the Source and Target Key should be the same as the Instance ID of the Source or Target instances. E.g. the value of NOZZLE.NEQUIP_GUID_PK should be equal to the InstanceID of EQUIPMENT. Otherwise reading and writing of such a relationship won't work.

     

    Mapping relationships stored in a separate table

    For relationships that are stored in a separate table everything that is possible for a class is possible as well. So all steps described in Creation of New Class Mapping should be done as well. Let's create a mapping for such a relationship e.g. for the "DOCUMENT_HAS_PIPELINE" relationship (see Fig.30):

    • Open the Edit Relationship mapping dialog box
    • Define Storing Type: "SEPARATE_TABLE"
    • Define the tables where the relationships are stored. These are "PROC_LNK" and "KEY_LINK"
    • Map the InstanceID. This relationship has its own ID so a mapping is necessary. The ID is mapped to "PROC_LNK.LINK_ID".
    • Map Source and Target Keys:
      • Source Key (field with the ID of DOCUMENT): PROC_LNK.DWG_NAME
      • Target Key (field with the ID of PIPELINE): KEY_LINK.KEY_TAG

    • Once the relationship is stored in the two tables it is necessary to define the join rules (see Fig.31):
      • Joined Table Name: PROC_LNK
      • Joined Table Column Name: LINK_ID
      • Main Table Name: KEY_LINK
      • Main Table Column Name: LINK_ID

     

    ⇒Next Plant Project Database - Property Mapping

    ⇐Back to Plant Project Database - Class Mapping

    ⇑Main OPPID - How to use the Class Editor Mapping Extension for the Plant Project Database

    • Share
    • History
    • More
    • Cancel
    • Gerd.Eichler Created by Bentley Colleague Gerd.Eichler
    • When: Thu, Jan 21 2010 5:54 AM
    • Kestutis Mitkus Last revision by Bentley Colleague Kestutis Mitkus
    • When: Wed, Mar 6 2019 3:27 PM
    • Revisions: 9
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies