on 2024 Jun 19 9:32 AM
I have the following CDS entities
entity Book {
key id : Integer;
author : String;
title : String;
}
entity Summary {
book : Association to Book;
summary : String;
lang : String;
}
I'd like to have the summary of a book in different languages.
When I run the following command
cds compile model.cds -2 sql
I get the following DDL as output
CREATE TABLE my_app_Book (
id INTEGER NOT NULL,
author NVARCHAR(255),
title NVARCHAR(255),
PRIMARY KEY(id)
);
CREATE TABLE my_app_Summary (
book_id INTEGER,
summary NVARCHAR(255),
lang NVARCHAR(255)
);
However I was also expecting a FOREIGN KEY on book_id to relate the two tables.
Is this a bug or expected behaviour ?
If this is actually the expectation, then is there any way I can configure my CDS such that the DB table schema can clearly link the two tables ?
Request clarification before answering.
The foreign key is generated in your example. The foreign key of "Book" in "Summary" is "book_id". What is the problem here?
If you want to make it more explicit and also generate a foreign key constraint to enforce referential integrity, please consult our documentation to learn more about foreign key constraints.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Setting
{"cds": {"features": {"assert_integrity": "db"}}}
in my .cdsrc.json did the trick
User | Count |
---|---|
41 | |
15 | |
10 | |
9 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.