diff --git a/guides/databases/cql-to-sql.md b/guides/databases/cql-to-sql.md index d28be9284..7d60f49d2 100644 --- a/guides/databases/cql-to-sql.md +++ b/guides/databases/cql-to-sql.md @@ -49,7 +49,7 @@ SELECT from Books where genre.name != 'Science Fiction'; The result set includes all books where genre is not 'Science Fiction', including the ones with an unspecified genre. In contrast, using SQL's `<>` operator, the ones with unspecified genre would be excluded. -The CQL behavior is consistent with common programming languages like JavaScript and Java, as well as with OData semantics. It is implemented in database by, the translation of `!=` to `IS NOT` in SQLite, or to `IS DISTINCT FROM` in standard SQL, and to an equivalent polyfill in SAP HANA. +The CQL behavior is consistent with common programming languages like JavaScript and Java, and with OData semantics. The runtime implements this by translating `!=` to `IS DISTINCT FROM` in standard SQL databases (PostgreSQL, H2), and to equivalent polyfills using `CASE` expressions in SAP HANA and SQLite. > [!tip] Prefer == and != > Prefer using `==` and `!=` in most cases to avoid unexpected `null` results. Only use `=` and `<>` if you _really_ want SQL's three-valued logic behavior. @@ -83,6 +83,9 @@ The compiler translates this operator to the best-possible equivalent in the tar Following are portable functions supported by CAP. You can safely use these in CDS view definitions and runtime queries expressed in CQL. The compiler translates them to the best-possible database-specific native SQL equivalents. +> [!note] Database-Specific Behavior +> While CAP aims for consistent behavior, some functions may exhibit subtle differences across databases due to underlying SQL dialect variations. Test critical functionality on your target database. + String functions: - `concat(x,y,...)` diff --git a/guides/databases/initial-data.md b/guides/databases/initial-data.md index e3ec3ee78..3449346f2 100644 --- a/guides/databases/initial-data.md +++ b/guides/databases/initial-data.md @@ -81,7 +81,21 @@ Common rules apply to text content in `.csv` files, like: | Numeric content should be treated as texts | -> enclose in double quotes | | Boolean values should be treated as text | -> enclose in double quotes | +## Data Loading Order +CAP loads CSV files in **alphabetical order by filename**. When tables have foreign key relationships, ensure parent tables load before child tables to avoid constraint violations. + +**Example:** +``` +db/data/ +├── sap.capire.bookshop-Authors.csv # Loads first (parent) +└── sap.capire.bookshop-Books.csv # Loads second (references Authors) +``` + +The filename prefix ensures correct order: `Authors` loads before `Books` alphabetically. If you encounter foreign key violations, verify your file naming follows dependency order. + +> [!tip] Large Datasets +> For datasets with thousands of rows, consider using database-specific bulk loading tools instead of CSV files. The CSV mechanism loads all data in a single transaction, which can cause memory issues and long startup times. ## Initial vs Test Data