Skip to content

pacx rel create nn

github-actions[bot] edited this page Dec 12, 2023 · 2 revisions

Creates a many-to-many relationship between two tables

Usage

This command reduces to almost 0 the effort required to create implicit or explicit many-to-many relationships between Dataverse tables.

An implicit many-to-many relationship is the classic many-to-many relationship, where the relationship table is created automatically by Dataverse when you create the relationship between two tables.

An explicit many-to-many relationship is a relationship where you create the relationship table manually, and then you create the relationship between the relationship table and the two tables you want to relate. Explicit many-to-many relationships can have a lot of advantages (e.g. you can add additional attributes in the relationship table), and tipically have a primary column of type autonumber. If you don't specify explicit information for the relationship talbe, the command will create it assuming that:

  • The entity schema name is the concatenation between the schema names of the two tables to relate (publisher prefix removed automatically)
  • The display name is the concatenation between the display names of the two tables to relate, separated by dash -
  • The primary column is an autonumber with format {initial of table1}{initial of table2}-{SEQNUM:10} (e.g. if the two tables are Account and Contact, the primary column value will be AC-0000000001)
  • Audit for the intersection table is disabled
  • The intersection table ownership is UserOwned
  • The primary column is not required (it's autogenerated)
  • The lookup attributes against the two tables have display name equal to the display name of each table
  • The lookup attributes against the two tables have schema name equal to the schema name of each table + id suffix
  • The lookup attributes against the two tables have Referential/Restrict behavior

Thus, if you have two tables account and contact, and you want to create a many-to-many relationship between them, you can simply type:

pacx rel create nn -t1 account -t2 contact
 --- or ---
pacx rel create nn -t1 account -t2 contact --explicit

All other arguments are optional.

If you are creating an implicit many-to-many relationship, the schema name of the relationship is built concatenating the schema names of the two tables to relate (publisher prefix removed automatically). There are some cases where this concatenation is not enough to create a unique schema name for the relationship table. In this case, you can use the --suffix option to specify a suffix to apply on the relationship schema name, or you can use --schemaName option to explicitly indicate a custom schema name for the relationship.

Arguments

Long Name Short Name Required? Description Default value Valid values
table1 t1 Y The first table (schema name) - String
table2 t2 Y The second table (schema name) - String
schemaName sn N The name of the table that manages the intersection between the two tables. If not specified, is calculated concatenating the schema names of the two entities. - String
suffix sns N The suffix to be appended to the schema name of the intersection table. Is considered only if --schemaName is not provided. - String
menuBehavior1 m1 N Indicates how the table1 is displayed in the table2 navbar DoNotDisplay UseCollectionName, UseLabel, DoNotDisplay
menuLabel1 ml1 N Indicates the menu label used to display table1 records in table2 navbar. To be specified only if the menuBehavior arg is set to UseLabel - String
menuGroup1 mg1 N Indicates the menu group that will contain table1 label in table2 navbar. To be specified only if the menuBehavior arg is set to UseLabel or UseCollectionName Details Details, Sales, Service, Marketing
menuOrder1 mo1 N Indicates the sequence used to display table1 label in table2 navbar. To be specified only if the menuBehavior arg is set to UseLabel or UseCollectionName 10000 Int32
menuBehavior2 m2 N Indicates how the table2 entity is displayed in the table1 navbar DoNotDisplay UseCollectionName, UseLabel, DoNotDisplay
menuLabel2 ml2 N Indicates the menu label used to display table2 records in table1 navbar. To be specified only if the menuBehavior arg is set to UseLabel - String
menuGroup2 mg2 N Indicates the menu group that will contain table2 label in table1 navbar. To be specified only if the menuBehavior arg is set to UseLabel or UseCollectionName Details Details, Sales, Service, Marketing
menuOrder2 mo2 N Indicates the sequence used to display table2 label in table1 navbar. To be specified only if the menuBehavior arg is set to UseLabel or UseCollectionName 10000 Int32
solution s N The name of the unmanaged solution to which you want to add this relationship. - String
explicit e N Indicates whether the relationship is an explicit or implicit relationship. False true, false
name n N Only for explicit relationships. The display name of the intersect table. - String
plural p N Only for explicit relationships. The plural display name of the intersect table. - String
description d N Only for explicit relationships. The description of the intersect table. - String
ownership o N Only for explicit relationships. The ownership of the intersect table UserOwned None, UserOwned, TeamOwned, BusinessOwned, OrganizationOwned, BusinessParented, Filtered
audit a N Only for explicit relationships. Indicates whether audit is enabled False true, false
primaryAttributeName pan N Only for explicit relationships. The display name of the primary attribute of the intersect table. Code String
primaryAttributeSchemaName pas N Only for explicit relationships. The schema name of the primary attribute of the intersect table. If not specified, is deducted from the display name - String
primaryAttributeDescription pad N Only for explicit relationships. The description of the primary attribute of the intersect table. - String
primaryAttributeAutoNumberFormat paan N Only for explicit relationships. If not specified, it is assumed as {initial of table1}{initial of table2}-{SEQNUM:10}. To generate a simple text field instead, pass "". - String
primaryAttributeRequiredLevel par N Only for explicit relationships. Indicates whether the primary attribute of the intersect table is required or not. None None, SystemRequired, ApplicationRequired, Recommended
primaryAttributeMaxLength palen N Only for explicit relationship. Indicates the len of the primary attribute. Is set to 20 in case of autonumber field, 100 in case of text field. - Int32
cascadeAssign1 caass1 N Only for explicit relationship. The behavior to apply to relationship table records when the table1 record is assigned to another owner (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeArchive1 caarc1 N Only for explicit relationship. The behavior to apply to relationship table records when the table1 record is archived (not available via UI) (default: NoCascade) - see description
cascadeShare1 cas1 N Only for explicit relationship. The behavior to apply to relationship table records when the table1 record is shared (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeUnshare1 cau1 N Only for explicit relationship. The behavior to apply to relationship table records when the table1 record is unshared (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeDelete1 cad1 N Only for explicit relationship. The behavior to apply to relationship table when the table1 record is deleted (values: Restrict, RemoveLink) (default: Restrict) Restrict see description
cascadeMerge1 cam1 N Only for explicit relationship. The behavior to apply to relationship table records when the table1 record is merged to another one (not available via UI) (default: NoCascade) - see description
cascadeReparent1 car1 N Only for explicit relationship. The behavior to apply to relationship table records when the table1 record is reparented (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeAssign2 caass2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is assigned to another owner (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeArchive2 caarc2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is archived (not available via UI) (default: NoCascade) - see description
cascadeShare2 cas2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is shared (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeUnshare2 cau2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is unshared (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
cascadeDelete2 cad2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is deleted (values: Restrict, RemoveLink) (default: Restrict) Restrict see description
cascadeMerge2 cam2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is merged to another one (not available via UI) (default: NoCascade) - see description
cascadeReparent2 car2 N Only for explicit relationship. The behavior to apply to relationship table records when the table2 record is reparented (values: Cascade, Active, UserOwned, NoCascade) (default: NoCascade) - see description
lookupDisplayName1 ldn1 N Only for explicit relationship. The display name of the lookup attribute vs table1. If not specified, the display name of the parent table is taken as default. - String
lookupSchemaName1 lsn1 N Only for explicit relationship. The schema name of the lookup attribute vs table1. If not specified, the - String
requiredLevel1 r1 N Only for explicit relationship. The required level of the lookup attribute vs table1. SystemRequired None, SystemRequired, ApplicationRequired, Recommended
lookupDisplayName2 ldn2 N Only for explicit relationships. The display name of the lookup attribute vs table2. If not specified, the display name of the parent table is taken as default. - String
lookupSchemaName2 lsn2 N Only for explicit relationships. The schema name of the lookup attribute vs table2. If not specified, the - String
requiredLevel2 r2 N Only for explicit relationships. The required level of the lookup attribute vs table2. SystemRequired None, SystemRequired, ApplicationRequired, Recommended

Command list

Clone this wiki locally