Skip to content

Commit

Permalink
Implement multi-column primary keys day_obs + seq_num for cdb
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrondel committed Sep 10, 2024
1 parent 2096231 commit f26bc16
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 79 deletions.
114 changes: 88 additions & 26 deletions yml/cdb_latiss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ tables:
- name: exposure
"@id": "#exposure"
primaryKey:
- "#exposure.exposure_id"
- "#exposure.day_obs"
- "#exposure.seq_num"
constraints:
- name: un_day_obs_seq_num
"@id": "#exposure.un_day_obs_seq_num"
- name: un_exposure_day_obs_seq_num
"@id": "#exposure.un_exposure_day_obs_seq_num"
"@type": Unique
description: Ensure day_obs plus seq_num is unique.
columns:
- "#exposure.day_obs"
- "#exposure.seq_num"
- name: un_exposure_exposure_id
"@id": "#exposure.un_exposure_exposure_id"
"@type": Unique
description: Ensure exposure_id is unique.
columns:
- "#exposure.exposure_id"
columns:
- name: exposure_id
"@id": "#exposure.exposure_id"
Expand All @@ -40,11 +47,13 @@ tables:
datatype: int
nullable: false
description: Day of observation.
ivoa:ucd: meta.id.part
- name: seq_num
"@id": "#exposure.seq_num"
datatype: int
nullable: false
description: Sequence number.
ivoa:ucd: meta.id.part
- name: physical_filter
"@id": "#exposure.physical_filter"
datatype: string
Expand Down Expand Up @@ -299,17 +308,18 @@ tables:
- name: exposure_flexdata
"@id": "#exposure_flexdata"
primaryKey:
- "#exposure_flexdata.obs_id"
- "#exposure_flexdata.day_obs"
- "#exposure_flexdata.seq_num"
- "#exposure_flexdata.key"
constraints:
- name: fk_exposure_flexdata_obs_id
"@id": "#exposure_flexdata.fk_obs_id"
- name: fk_exposure_flexdata_day_obs_seq_num
"@id": "#exposure_flexdata.fk_exposure_flexdata_day_obs_seq_num"
"@type": ForeignKey
description: Flex data obs_id must be an Exposure exposure_id.
columns: ["#exposure_flexdata.obs_id"]
referencedColumns: ["#exposure.exposure_id"]
description: Flex data day_obs must be an Exposure day_obs
columns: ["#exposure_flexdata.day_obs", "#exposure_flexdata.seq_num"]
referencedColumns: ["#exposure.day_obs", "#exposure.seq_num"]
- name: fk_exposure_flexdata_key
"@id": "#exposure_flexdata.fk_key"
"@id": "#exposure_flexdata.fk_exposure_flexdata_key"
"@type": ForeignKey
description: Flex data key must be listed in the schema.
columns: ["#exposure_flexdata.key"]
Expand All @@ -320,6 +330,18 @@ tables:
datatype: long
nullable: false
description: Unique identifier.
- name: day_obs
"@id": "#exposure_flexdata.day_obs"
datatype: int
nullable: false
description: Day of observation.
ivoa:ucd: meta.id.part
- name: seq_num
"@id": "#exposure_flexdata.seq_num"
datatype: int
nullable: false
description: Sequence number.
ivoa:ucd: meta.id.part
- name: key
"@id": "#exposure_flexdata.key"
datatype: string
Expand Down Expand Up @@ -367,19 +389,26 @@ tables:
primaryKey:
- "#ccdexposure.ccdexposure_id"
constraints:
- name: un_exposure_id_detector
"@id": "#ccdexposure.un_exposure_id_detector"
- name: un_ccdexposure_ccdexposure_id
"@id": "#ccdexposure.un_ccdexposure_ccdexposure_id"
"@type": Unique
description: Ensure ccdexposure_id is unique.
columns:
- "#ccdexposure.ccdexposure_id"
- name: un_ccdexposure_day_obs_seq_num_detector
"@id": "#ccdexposure.un_ccdexposure_day_obs_seq_num_detector"
"@type": Unique
description: Ensure exposure_id plus detector is unique.
description: Ensure day_obs plus seq_num plus detector is unique.
columns:
- "#ccdexposure.exposure_id"
- "#ccdexposure.day_obs"
- "#ccdexposure.seq_num"
- "#ccdexposure.detector"
- name: fk_exposure_id
"@id": "#ccdexposure.fk_exposure_id"
- name: fk_ccdexposure_day_obs_seq_num
"@id": "#ccdexposure.fk_ccdexposure_day_obs_seq_num"
"@type": ForeignKey
description: exposure_id must be in the Exposure table.
columns: ["#ccdexposure.exposure_id"]
referencedColumns: ["#exposure.exposure_id"]
description: day_obs must be in the Exposure table.
columns: ["#ccdexposure.day_obs", "#ccdexposure.seq_num"]
referencedColumns: ["#exposure.day_obs", "#exposure.seq_num"]
columns:
- name: ccdexposure_id
"@id": "#ccdexposure.ccdexposure_id"
Expand All @@ -392,6 +421,17 @@ tables:
datatype: long
nullable: false
description: Identifier of the exposure.
- name: day_obs
"@id": "#ccdexposure.day_obs"
datatype: int
nullable: false
description: Day of observation.
ivoa:ucd: meta.id.part
- name: seq_num
"@id": "#ccdexposure.seq_num"
datatype: int
nullable: false
description: Sequence number.
ivoa:ucd: meta.id.part
- name: detector
"@id": "#ccdexposure.detector"
Expand All @@ -411,7 +451,7 @@ tables:
- "#ccdexposure_camera.ccdexposure_id"
constraints:
- name: fk_ccdexposure_camera_ccdexposure_id
"@id": "#ccdexposure_camera.fk_ccdexposure_id"
"@id": "#ccdexposure_camera.fk_ccdexposure_camera_ccdexposure_id"
"@type": ForeignKey
description: exposure_id must be in the Exposure table.
columns: ["#ccdexposure_camera.ccdexposure_id"]
Expand All @@ -438,13 +478,13 @@ tables:
- "#ccdexposure_flexdata.key"
constraints:
- name: fk_ccdexposure_flexdata_obs_id
"@id": "#ccdexposure_flexdata.fk_obs_id"
"@id": "#ccdexposure_flexdata.fk_ccdexposure_flexdata_obs_id"
"@type": ForeignKey
description: Flex data obs_id must be a CcdExposure ccdexposure_id.
columns: ["#ccdexposure_flexdata.obs_id"]
referencedColumns: ["#ccdexposure.ccdexposure_id"]
- name: fk_ccdexposure_flexdata_key
"@id": "#ccdexposure_flexdata.fk_key"
"@id": "#ccdexposure_flexdata.fk_ccdexposure_flexdata_key"
"@type": ForeignKey
description: Flex data key must be listed in the schema.
columns: ["#ccdexposure_flexdata.key"]
Expand Down Expand Up @@ -500,7 +540,8 @@ tables:
- name: visit1
"@id": "#visit1"
primaryKey:
- "#visit1.visit_id"
- "#visit1.day_obs"
- "#visit1.seq_num"
columns:
- name: visit_id
"@id": "#visit1.visit_id"
Expand All @@ -524,11 +565,13 @@ tables:
datatype: int
nullable: false
description: Day of observation.
ivoa:ucd: meta.id.part
- name: seq_num
"@id": "#visit1.seq_num"
datatype: int
nullable: false
description: Sequence number.
ivoa:ucd: meta.id.part
- name: physical_filter
"@id": "#visit1.physical_filter"
datatype: string
Expand Down Expand Up @@ -779,20 +822,39 @@ tables:
- name: visit1_quicklook
"@id": "#visit1_quicklook"
primaryKey:
- "#visit1_quicklook.visit_id"
- "#visit1_quicklook.day_obs"
- "#visit1_quicklook.seq_num"
constraints:
- name: fk_visit1_quicklook_obs_id
"@id": "#visit1_quicklook.fk_obs_id"
"@id": "#visit1_quicklook.fk_visit1_quicklook_obs_id"
"@type": ForeignKey
description: Quicklook visit_id must be an Exposure exposure_id.
columns: ["#visit1_quicklook.visit_id"]
referencedColumns: ["#exposure.exposure_id"]
- name: fk_visit1_quicklook_day_obs_seq_num
"@id": "#visit1_quicklook.fk_visit1_quicklook_day_obs_seq_num"
"@type": ForeignKey
description: Quicklook day_obs must be an Exposure day_obs.
columns: ["#visit1_quicklook.day_obs", "#visit1_quicklook.seq_num"]
referencedColumns: ["#exposure.day_obs", "#exposure.seq_num"]
columns:
- name: visit_id
"@id": "#visit1_quicklook.visit_id"
datatype: long
nullable: false
description: Unique identifier.
- name: day_obs
"@id": "#visit1_quicklook.day_obs"
datatype: int
nullable: false
description: Day of observation.
ivoa:ucd: meta.id.part
- name: seq_num
"@id": "#visit1_quicklook.seq_num"
datatype: int
nullable: false
description: Sequence number.
ivoa:ucd: meta.id.part
- name: n_inputs
"@id": "#visit1_quicklook.n_inputs"
datatype: int
Expand Down Expand Up @@ -954,7 +1016,7 @@ tables:
- "#ccdvisit1_quicklook.ccdvisit_id"
constraints:
- name: fk_ccdvisit1_quicklook_obs_id
"@id": "#ccdvisit1_quicklook.fk_obs_id"
"@id": "#ccdvisit1_quicklook.fk_ccdvisit1_quicklook_obs_id"
"@type": ForeignKey
description: Quicklook ccdvisit_id must be a CcdExposure ccdexposure_id.
columns: ["#ccdvisit1_quicklook.ccdvisit_id"]
Expand Down
Loading

0 comments on commit f26bc16

Please sign in to comment.