nerdexam
Salesforce

PDI · Question #27

A developer created a custom order management app that uses an Apex class. The order is represented by an Order object and an Orderltem object that has a master-detail relationship to Order. During…

The correct answer is C. Create a junction object between Orderltem and Order. To allow existing OrderItem records to be associated with multiple Orders, such as when an order is split, a many-to-many relationship using a junction object between OrderItem and Order is necessary.

Submitted by devops_kid· Apr 18, 2026Data Modeling and Management

Question

A developer created a custom order management app that uses an Apex class. The order is represented by an Order object and an Orderltem object that has a master-detail relationship to Order. During order processing, an order may be split into multiple orders. What should a developer do to allow their code to move some existing Orderltem records to a new Order record?

Options

  • AChange the master-detail relationship to an external lookup relationship.
  • BAdd without sharing to the Apex class declaration.
  • CCreate a junction object between Orderltem and Order.
  • DSelect the Allow reparenting option on the master-detail relationship.

How the community answered

(62 responses)
  • A
    2% (1)
  • B
    10% (6)
  • C
    82% (51)
  • D
    6% (4)

Why each option

To allow existing OrderItem records to be associated with multiple Orders, such as when an order is split, a many-to-many relationship using a junction object between OrderItem and Order is necessary.

AChange the master-detail relationship to an external lookup relationship.

Changing to an external lookup relationship would still maintain a one-to-many relationship and does not inherently allow an OrderItem to relate to multiple Orders, nor does it typically relate to 'moving' internal records.

BAdd without sharing to the Apex class declaration.

Adding `without sharing` to an Apex class declaration impacts security and visibility, but it does not change the underlying data model or relationship types to allow records to be moved or associated with multiple parents.

CCreate a junction object between Orderltem and Order.Correct

Creating a junction object between OrderItem and Order converts the relationship to many-to-many, allowing a single OrderItem record to be flexibly associated with multiple Order records, which is crucial when an order is split into multiple new orders and items might relate to more than one resulting order or are shared.

DSelect the Allow reparenting option on the master-detail relationship.

Selecting 'Allow reparenting' on a master-detail relationship enables a child record to change its single parent, but it does not allow a single child OrderItem to be simultaneously associated with multiple Order records.

Concept tested: Many-to-Many Relationships with Junction Objects

Source: https://help.salesforce.com/s/articleView?id=sf.overview_of_custom_object_relationships.htm&type=5

Topics

#Data Modeling#Master-Detail Relationship#Junction Objects#Many-to-Many Relationships

Community Discussion

No community discussion yet for this question.

Full PDI Practice