Home » Data model (DataTypes) » RelationTypes


  • To create dependency between 2 types is called relation between the types.
  • Relation is basically used between 2 itemtypes in SAP Commerce Cloud. So each of them can also access the instance of its partner itemtype. It’s a relation between 2 table in the terms of Database.

One to Many Relation:

User and Order are itemtypes. Also we can use the term UserModel and OrderModel in further discussion.

User and Order is having one to many relation. Which means :

  • User(UserModel) can access it’s Orders(List Of Orders)

Example : Create a one to many relation between User and Orders.Which means one User can have relation with many orders. Following is the example of one to many relation.

<relation code="User2Orders" generate="true" localized="false" autocreate="true">
    <sourceElement type="User" cardinality="one" qualifier="user">
        <modifiers read="true" write="true" search="true" optional="false"/>
    <targetElement type="Order" cardinality="many" qualifier="orders">
        <modifiers read="true" write="true" search="true" optional="true" partof="true"/>


There are Two elements are used to create  a relation: sourceElement  and  targetElement.
sourceElement is  User, targetElement is Order.
User’s cardinality is One and Order’s cardinality is Many. So this relation called “One to Many Relation”

One-to-many relations (1:n)

One User can have many orders:


Many-to-Many relations:

Let’s Take an example of Products and Promotions.
the relation between both items are many to many relation.

1.One product can have many promotions or discounts.


2.One promotion can be applied on many products.



<relation code="ProductPromotionRelation"
   <deployment table="ProdPromRelations" typecode="5018"/>
   <sourceElement qualifier="products" type="Product" cardinality="many">
      <modifiers read="true" write="true" search="true" optional="true"/>
<targetElement qualifier="promotions" type="ProductPromotion" cardinality="many">
      <modifiers read="true" write="true" search="true" optional="true"/>