@@ -210,3 +210,111 @@ Run tests with `coverage`:
210
210
``` bash
211
211
pytest --cov=isimip_publisher
212
212
```
213
+
214
+
215
+ Database schema
216
+ ---------------
217
+
218
+ The database schema is automatically created when ` insert_datasets ` or ` init ` is used the first time. The tool creates 3 main tables:
219
+
220
+ ```
221
+ Table "public.datasets"
222
+ Column | Type | Collation | Nullable | Default
223
+ -------------+-----------------------------+-----------+----------+---------
224
+ id | uuid | | not null |
225
+ target_id | uuid | | |
226
+ name | text | | not null |
227
+ path | text | | not null |
228
+ version | character varying(8) | | not null |
229
+ size | bigint | | not null |
230
+ specifiers | jsonb | | not null |
231
+ identifiers | text[] | | not null |
232
+ public | boolean | | not null |
233
+ tree_path | text | | |
234
+ rights | text | | |
235
+ created | timestamp without time zone | | |
236
+ updated | timestamp without time zone | | |
237
+ published | timestamp without time zone | | |
238
+ archived | timestamp without time zone | | |
239
+
240
+
241
+ Table "public.files"
242
+ Column | Type | Collation | Nullable | Default
243
+ ---------------+-----------------------------+-----------+----------+---------
244
+ id | uuid | | not null |
245
+ dataset_id | uuid | | |
246
+ target_id | uuid | | |
247
+ name | text | | not null |
248
+ path | text | | not null |
249
+ version | character varying(8) | | not null |
250
+ size | bigint | | not null |
251
+ checksum | text | | not null |
252
+ checksum_type | text | | not null |
253
+ netcdf_header | jsonb | | |
254
+ specifiers | jsonb | | not null |
255
+ identifiers | text[] | | not null |
256
+ created | timestamp without time zone | | |
257
+ updated | timestamp without time zone | | |
258
+
259
+
260
+ Table "public.resources"
261
+ Column | Type | Collation | Nullable | Default
262
+ ----------+-----------------------------+-----------+----------+---------
263
+ id | uuid | | not null |
264
+ doi | text | | not null |
265
+ title | text | | not null |
266
+ version | text | | |
267
+ paths | text[] | | not null |
268
+ datacite | jsonb | | not null |
269
+ created | timestamp without time zone | | |
270
+ updated | timestamp without time zone | | |
271
+ ```
272
+
273
+ The many-to-many relation between ` datasets ` and ` resources ` is implemented using a seperate table:
274
+
275
+ ```
276
+ Table "public.resources_datasets"
277
+ Column | Type | Collation | Nullable | Default
278
+ -------------+------+-----------+----------+---------
279
+ resource_id | uuid | | |
280
+ dataset_id | uuid | | |
281
+ ```
282
+
283
+ Additional tables are created for the search and tree functionality of the repository.
284
+
285
+ ```
286
+ Table "public.search"
287
+ Column | Type | Collation | Nullable | Default
288
+ ------------+-----------------------------+-----------+----------+---------
289
+ dataset_id | uuid | | not null |
290
+ vector | tsvector | | not null |
291
+ created | timestamp without time zone | | |
292
+ updated | timestamp without time zone | | |
293
+ ```
294
+
295
+ ```
296
+ Table "public.trees"
297
+ Column | Type | Collation | Nullable | Default
298
+ -----------+-----------------------------+-----------+----------+---------
299
+ id | uuid | | not null |
300
+ tree_dict | jsonb | | not null |
301
+ created | timestamp without time zone | | |
302
+ updated | timestamp without time zone | | |
303
+ ```
304
+
305
+ Two materialized views are used to allow a fast lookup to all ` identifiers ` (with the list of corresponding specifiers), as well as all ` words ` (the list of tokens for the search):
306
+
307
+ ```
308
+ Materialized view "public.identifiers"
309
+ Column | Type | Collation | Nullable | Default
310
+ ------------+------+-----------+----------+---------
311
+ identifier | text | | |
312
+ specifiers | json | | |
313
+ ```
314
+
315
+ ```
316
+ Materialized view "public.words"
317
+ Column | Type | Collation | Nullable | Default
318
+ --------+------+-----------+----------+---------
319
+ word | text | | |
320
+ ```
0 commit comments