Elffuss BraidHub

kikocis/EDC public

main · 1.6 KiBRenderedRawPermalink
1# SQL-based `ContractNegotiationStore` - technical proposal
2
3**_Note that the SQL statements (DDL) are specific to and only tested with PostgreSQL. Using it with other RDBMS may
4work but might have unexpected side effects!_**
5
6## 1. Table schema
7
8see [schema.sql](src/main/resources/contract-negotiation-schema.sql).
9
10As an alternative to storing `ContractAgreement`s in a dedicated table, it could also be serialized and stored as column
11in the `contract_negotiation` table. However, we will need to be able to list all contract agreements at some point, so
12it seemed more future-proof to have it separate.
13
14## 2. Translating the `ContractNegotiationStore` into SQL statements
15
16All SQL contants such as table names, column names, statement templates etc. are stored in an interface
17called `ContractNegotiationStatements`. Column names are declared directly in that interface, as they likely won't
18change between different DB technologies, but all statements are then implemented in the `PostgreStatements` class.
19
20## Create a flexible query API to accommodate `QuerySpec`
21
22_For the first version, only the `limit` and `offset` arguments from the `QuerySpec` will be used._
23
24For subsequent versions it is recommended to re-use the `Clause` interface and its implementors, that were originally
25implemented for CosmosDB, and create an equivalent set of clauses for SQL. Thus, there would be a `Limit-`, `Offset-`
26, `Order-` and `WhereClause` for SQL.
27
28That way, dialect-dependent variants can be implemented should the need arise, because the actual SQL statement is
29encoded in those clauses, offering a fluent Java API.