CSV Enhancement - Relationships
Relationships
-
CSV ingestion supports two kinds of relationships:
-
Deterministic (Schema-driven) These relationships require that the entity be referred to in the record's targetKind schema under an attribute having
x-osdu-relationship
tag. Because they are present in the schema, they are represented directly as attributes in thedata
block of the record. -
Non Deterministic (Data-driven) These relationships do not require any mention in the schema. They are represented within the
data.relationships
block of the record.
-
-
ExtensionProperties block in the file metadata record is used to provide additional information for ingestion. We can use this block to provide relationship information. There are three ways of providing this information:
-
In the
relationships
block, with the entity name and a list of parent record ID(s). The ID(s) provided here are directly used to establish relationships. -
In the
relatedNaturalKey
block, as an entity that requires a search of the targetKind using the natural keys provided to establish a relationship.- sourceColumn: Column name of the CSV file which refers to the key parent attribute.
- targetKind: Schema ID of the parent record.
- targetAttribute: The key attribute of the parent record which is used to search the parent record.
- Pre-requisites: CSV file should have the key attributes of the parent records.
-
{
"ExtensionProperties": {
"relationships": {
"project": {
"ids": [
"<recordId1>"
]
},
"well": {
"ids": [
"<recordId2>"
"<recordId3>"
]
}
},
"relatedNaturalKey": {
"wellbore": {
"targetKind":"<<authority>:<source>:<entityType>:<version>>",
"keys": [
{
"sourceColumn":"UWI",
"targetAttribute":"uwi"
}
]
}
}
}
}
- The schema of the record should have information about attributes that contain deterministic relationships.
- The EntityType field within the
x-osdu-relationship
block should contain the entity that needs to be matched from the ExtensionProperties block.
- The EntityType field within the
{
"properties": {
"wellId": {
"type":"string",
"pattern":"^[\\w\\-\\.]+:\\-\\-well:[\\w\\-\\.\\:\\%]+:[0-9]*$",
"x-osdu-relationship": [
{
"GroupType":"master-data",
"EntityType":"well"
}
]
},
"wellboreId": {
"type":"string",
"pattern":"^[\\w\\-\\.]+:\\-\\-wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$",
"x-osdu-relationship": [
{
"GroupType":"master-data",
"EntityType":"wellbore"
}
]
}
}
}
- The final record will then have the relationships defined as below:
{
"data": {
"relationships": {
"project": {
"ids": [
"<recordId1>"
]
}
},
"wellId":"<recordId2>",
"wellboreId":"<recordId5>"
}
}