addDimensionForeignKey¶
-
lsst.daf.butler.
addDimensionForeignKey
(tableSpec: ddl.TableSpec, dimension: Dimension, *, primaryKey: bool, nullable: bool = False, constraint: bool = True) → ddl.FieldSpec¶ Add a field and possibly a foreign key to a table specification.
The field will reference the table for the given
Dimension
.- Parameters
- tableSpec
ddl.TableSpec
Specification the field and foreign key are to be added to.
- dimension
Dimension
Dimension to be referenced. If this dimension has required dependencies, those must have already been added to the table. A field will be added that correspond to this dimension’s primary key, and a foreign key constraint will be added only if the dimension is associated with a table of its own.
- primaryKey
bool
If
True
, the new field will be added as part of a compound primary key for the table.- nullable
bool
, optional If
False
(default) the new field will be added with a NOT NULL constraint.- constraint
bool
If
False
(True
is default), just add the field, not the foreign key constraint.
- tableSpec
- Returns
- fieldSpec
ddl.FieldSpec
Specification for the field just added.
- fieldSpec