Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions guides/domain-modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ entity Projects { ...
entity Users { ...
projects : Composition of many Members on projects.user = $self;
}
entity Members { // link table
key project : Association to Projects;
key user : Association to Users;
entity Members: cuid { // link table
project : Association to Projects;
user : Association to Users;
}
```

Expand All @@ -529,6 +529,7 @@ entity Users { ...
```

Behind the scenes the equivalent of the model above would be generated, with the link table called `Projects.members` and the backlink association to `Projects` in there called `up_`.
Consider that for SAP Fiori elements 'project' and 'user' shall not be keys, even if their combination is unique, because as keys those fields can't be edited on the UI. In this case a different key is required, for example a UUID, and the unique constraint for `project` and `user` can be expressed via `@assert.unique`.

### Compositions

Expand Down Expand Up @@ -570,7 +571,16 @@ entity Orders { ...

[Learn more about Compositions of Aspects in the _CDS Language Reference_](../cds/cdl#managed-compositions){ .learn-more}

Behind the scenes this will add an entity named `Orders.Items` with a backlink association named `up_`, so effectively generating the same model as above.
Behind the scenes this will add an entity named `Orders.Items` with a backlink association named `up_`, so effectively generating the same model as above. You can annotate the inline composition with UI annotations as follows:

```cds
annotate Orders.Items with @(
UI.LineItem : [
{Value: pos},
{Value: quantity},
],
);
```

## Aspects

Expand Down