Skip to content

ForeignKey

Helper class for defining foreign keys of tables.

NameTypeDescriptionOptional
column_namestrName of the foreign key column.No
link_tostrTable and column name that the foreign key links to, in the format TableName.ColumnName. ColumnName column must be defined as CandidateKey of the GNNTable TableName.No
is_featurestrIndicates whether the foreign key is to be considered a Graph Neural Network (GNN) feature. Default is False.Yes.

An instance of the ForeignKey class.

from relationalai_gnns import GNNTable, ForeignKey
foreign_key_1 = ForeignKey(column_name="classId", link_to="Classes.classId")
foreign_key_2 = ForeignKey(column_name="studentId", link_to="Students.studentId")
student_takes_class_table = GNNTable(
connector=connector,
name="StudentsTakeClass",
source="SYNTH_DB.SYNTH_SCHEMA.STUDENTS_TAKE_CLASS",
foreign_keys=[foreign_key_1, foreign_key_2]
)