Skip to content

Commit 05f7b5d

Browse files
dr-rodriguezkelle
andauthored
Some schema and documentation improvements (#94)
* Some schema and documentation improvements * Update docs/index.rst Co-authored-by: Kelle Cruz <kellecruz@gmail.com> --------- Co-authored-by: Kelle Cruz <kellecruz@gmail.com>
1 parent 9a87456 commit 05f7b5d

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

astrodbkit/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"Versions",
3535
"Parameters",
3636
"Regimes",
37+
"ParameterList",
38+
"AssociationList",
39+
"CompanionList",
40+
"SourceTypeList",
3741
]
3842
# REFERENCE_TABLES is a list of tables that do not link to the primary table.
3943
# These are treated separately from the other data tables that are all assumed to be linked to the primary table.

astrodbkit/schema_example_felis.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ tables:
3535
datatype: string
3636
length: 1000
3737
description: Publication description
38+
ivoa:ucd: meta.note
3839

3940

4041
- name: Telescopes
@@ -56,6 +57,7 @@ tables:
5657
datatype: string
5758
length: 30
5859
description: Publication reference; links to Publications table
60+
ivoa:ucd: meta.ref
5961

6062
constraints:
6163
- name: Telescopes_reference_Publications_name
@@ -158,8 +160,9 @@ tables:
158160
- name: comments
159161
"@id": "#Sources.comments"
160162
datatype: string
161-
length: 1000
163+
length: 100
162164
description: Free-form comments on this Source
165+
ivoa:ucd: meta.note
163166

164167

165168
indexes:
@@ -251,6 +254,7 @@ tables:
251254
datatype: string
252255
length: 30
253256
description: Photometry band for this measurement
257+
ivoa:ucd: instr.bandpass
254258
- name: ucd
255259
"@id": "#Photometry.ucd"
256260
datatype: string
@@ -261,37 +265,44 @@ tables:
261265
datatype: double
262266
description: Magnitude value for this entry
263267
fits:tunit: mag
268+
ivoa:ucd: phot.mag
264269
- name: magnitude_error
265270
"@id": "#Photometry.magnitude_error"
266271
datatype: double
267272
description: Uncertainty of this magnitude value
268273
fits:tunit: mag
274+
ivoa:ucd: stat.error;phot.mag
269275
- name: telescope
270276
"@id": "#Photometry.telescope"
271277
datatype: string
272278
length: 30
273279
description: Telescope, mission, or survey name; links to Telescopes table
280+
ivoa:ucd: instr.tel
274281
- name: instrument
275282
"@id": "#Photometry.instrument"
276283
datatype: string
277284
length: 30
278285
description: Instrument name; links to Instruments table
286+
ivoa:ucd: instr
279287
- name: epoch
280288
"@id": "#Photometry.epoch"
281289
datatype: double
282290
description: Decimal year
283291
fits:tunit: yr
292+
ivoa:ucd: time.epoch
284293
- name: comments
285294
"@id": "#Photometry.comments"
286295
datatype: string
287296
length: 1000
288297
description: Free-form comments for this entry
298+
ivoa:ucd: meta.note
289299
- name: reference
290300
"@id": "#Photometry.reference"
291301
datatype: string
292302
length: 30
293303
description: Publication reference; links to Publications table
294304
nullable: false
305+
ivoa:ucd: meta.ref
295306

296307
indexes:
297308
- name: PK_Photometry

docs/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,27 @@ These options can facilitate the creation of robust ingest scripts that are both
509509
and that can take care of validating input values before they get to the database.
510510

511511

512+
Advanced Database Considerations
513+
================================
514+
515+
Here we provide useful tips or guidance when working with **AstrodbKit**.
516+
517+
Handling Relationships Between Object Tables
518+
--------------------------------------------
519+
520+
Becuase **AstrodbKit** expects a single primary table, object tables that point back to it, and any number of reference tables, it can be difficult to handle relationships between object tables.
521+
522+
As an example, consider the scenario where you want to store companion information to your sources, such as a table to store the relationship with orbital separation and a separate one to store general parameters.
523+
You may be calling these CompanionRelationship and CompanionParameters, respectively.
524+
If you want to link them together, you might decide to specify that the companion in the CompanionRelationship table should be a foreign key to the CompanionParameters table.
525+
**However**, this will run into issues on database saving/loading as the output JSON files will no necessarily load tables in the order you expect.
526+
You might find it attempting to load CompanionParameters only to find that CompanionRelationship hasn't been loaded yet all the foreign keys are broken.
527+
528+
The better approach is to define a lookup table that will store the companion identifiers which will be used as the foreign keys.
529+
For example, a CompanionList table that both CompanionParameters and CompanionRelationship can refer to.
530+
This would be a reference table, similar to Telescopes or Publications, while CompanionParameters and CompanionRelationship would be object tables that require tying back to a specific source in the Sources table.
531+
Essentially, this is normalizing the database a bit further and serves to avoid some common issues with foreign keys.
532+
512533
Reference/API
513534
=============
514535

0 commit comments

Comments
 (0)