What are root and child entities in a RAP business object, and how do compositions work?
Say your answer out loud first.
Practise another way
A RAP business object is a tree. The root entity is the top node and each child entity cannot exist without its parent. In CDS the parent declares a composition to the child, and the child declares an association to parent.
In the behavior definition the root is the lock and authorization master, and children are dependent. Deleting a root deletes its children in a managed object, and you create children through the association.
A business object in RAP is a tree of CDS entities. The root entity is the top node. Child entities hang under it through compositions, a special kind of association that expresses existence dependency. A booking cannot exist without its travel.
CDS side
- Root:
define root view entity, withcomposition [0..*] of ZR_Booking as _Booking. - Child:
define view entity, withassociation to parent ZR_Travel as _Travel on $projection.TravelUUID = _Travel.TravelUUID. - Only the root carries the
rootkeyword. Children are ordinary view entities that name their parent.
Behavior side
- You must define behavior for the root. Child behavior definitions are optional but common.
- The root states
lock masterandauthorization master. Each child stateslock dependent by _Travelandauthorization dependent by _Travel. Dependent entities rely on the master's decision. - A child is created through its parent with a create-by-association:
association _Booking { create; }in the parent.
define behavior for ZR_Travel alias Travel
persistent table ztravel
lock master
authorization master ( instance )
{
create; update; delete;
association _Booking { create; }
}
define behavior for ZR_Booking alias Booking
persistent table zbooking
lock dependent by _Travel
authorization dependent by _Travel
{
update; delete;
field ( readonly ) TravelUUID;
association _Travel;
}
What the framework does for you
- In a managed BO, deleting the parent deletes its composition children.
- A save is one transaction for the whole tree, and locking is taken on the root.
- EML reads children with
READ ENTITIES ... ENTITY Travel BY \_Booking, and creates them withCREATE BY \_Booking.
Association versus composition. A plain association (for example to a customer) is only a join path. A composition means ownership, and it changes locking, deletion and the way the service exposes the child.
Note for services. A child entity needs its own expose line in the service definition.
Draws the tree, shows both sides of the composition, and ties it to lock, authorization and delete behavior.
Describes a composition as 'a join between two views'.
Forgetting the `association to parent` in the child view, or the `lock dependent by` line. The BDEF then fails its syntax check.
- What happens to children when you delete the root?
- Why must children name their parent in lock dependent by?
- How do you read all bookings of one travel with EML?
- What does `association _Travel;` in the child BDEF do?
2 official pages and 1 prep guide. Confidence: high. Checked 21 Nov 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Prep guide Backs the answer.