Showing results for 
Search instead for 
Did you mean: 

SAP CAP Many-to-Many relationship - Fiori Elements UI for maintenance

0 Kudos

Hello community,

let's say we have a data model as follows:

using { managed } from '@sap/cds/common';

namespace employee.catalog;

entity Student {
    key studentID: UUID;
    studentName: String;
    courses: Composition of many StudentToCourse on courses.student = $self;

entity Course {
    key courseID: UUID;
    courseName: String;
    students: Composition of many StudentToCourse on students.course = $self;

entity StudentToCourse {
    student: Association to Student;
    course: Association to Course;

Is there a way I can create a fiori elements UI to assign Students to Courses? I am thinking of a list report for students and on the object page a table that lists assigned courses including the option to assign new courses to the student.



Accepted Solutions (1)

Accepted Solutions (1)



two things that come to mind. First, entity names should be in the plural form, i.e. "entity Students...." and "entity Courses....". If you want navigation properties, then prefer Associations over Compositions. The latter is more suitable for entities with a header-item (one-to-many) relationship.

See Compositions

You should be able to use a @UI.ReferenceFacet in the Student object page to list all courses. Annotations should give you add/delete capabilities. Alternatively, you may start with a custom page and use the flexible programming model.

See Flexible Programming Model

0 Kudos

Hello Ulrich,

thank you for the answer.

Regarding the entity names: above example was just copied from this blog:

I was reading it and wondering whether FE UIs would be a good/ feasible approach to maintain many-to-many associations...

Answers (0)