-
Notifications
You must be signed in to change notification settings - Fork 17
04 Loading Relations
is-in-use sub attribute, value string,
plays in-use:status;
phone-number sub attribute,
value string,
plays in-use:account;
in-use sub relation,
relates status,
relates account;
pn,in_use
+7 171 898 0853,yes
+370 351 224 5176,no
+81 308 988 7153,yes
+54 398 559 0423,yes
+263 498 495 0617,yes
+81 746 154 2598,no
+63 815 962 6097,yes
...
{
"globalConfig": {...},
"attributes": {...},
"entities": {...},
"relations": { // all relations go here
"in-use": { // key for generator in relations, must be unique
"data": [ // files from which to load data
"src/test/resources/1.0.0/phoneCalls/in-use.csv"
],
"insert": {
"relation": "in-use", // relation type to insert
"players": [
{
"role": "status", // role that the player plays in the relation
"required": true, // required player - only relations in which this player is present are loaded
"match": {
"type": "is-in-use", // type of attribute player
"attribute": {
"column": "in_use" // column from which to load values
}
}
},
...
]
}
},
...
},
...
}
TypeDB Loader will check if the attributes you are trying to insert or match on are present in your schema. It will also ensure that all values in your data files adhere to the attribute's value type specified in your schema or try to cast them. If a value cannot be cast, it is not inserted, and the line written out into an error log see logging.
TypeDB Loader will also check if all roles are defined in the specified relations, and that the types of players specified actually play that role. If any of these conditions are not met, you will be told exactly what is incorrect in your config to be able to fix it easily.
See the full phone-calls schema here.
See the full phone-calls config file here.
See the full data file here.
Loading relations with entity/relation players, matched on attribute ownerships (incl. nested relations)
person sub entity,
...,
plays communication-channel:peer;
call sub relation,
...,
plays communication-channel:past-call;
# This is the new relation-with-relation:
communication-channel sub relation,
relates peer,
relates past-call; # this is a call relation playing past-call
peer_1,peer_2,call_started_at
+54 398 559 0423,+48 195 624 2025,2018-09-16T22:24:19
+263 498 495 0617,+33 614 339 0298,2018-09-11T22:10:34### 2018-09-12T22:10:34###2018-09-13T22:10:34 ###2018-09-14T22:10:34###2018-09-15T22:10:34###2018-09-16T22:10:34
+370 351 224 5176,+62 533 266 3426,2018-09-15T12:12:59
...
{
"globalConfig": {...},
"attributes": {...},
"entities": {...},
"relations": { // all relations go here
...,
"communication-channel": { // key for generator in relations, must be unique
"data": [ // files from which to load data
"src/test/resources/1.0.0/phoneCalls/communication-channel.csv"
],
"insert": {
"relation": "communication-channel", // relation type to insert
"players": [
{
"role": "peer", // role that the player plays in the relation
"required": true, // required player - only relations in which this player is present are loaded
"match": {
"type": "person", // entity type of player
"ownerships": [ // list of attribute Ownerships by which to match it
{
"attribute": "phone-number", // attribute type of matching attribute
"column": "peer_1" // column from which to load values
}
]
}
},
...
]
}
},
...
},
...
}
TypeDB Loader will check if the attributes you are trying to insert or match on are present in your schema. It will also ensure that all values in your data files adhere to the attribute's value type specified in your schema or try to cast them. If a value cannot be cast, it is not inserted, and the line written out into an error log see logging.
TypeDB Loader will also check if all roles are defined in the specified relations, and that the types of players specified actually play that role. If any of these conditions are not met, you will be told exactly what is incorrect in your config to be able to fix it easily.
See the full phone-calls schema here.
See the full phone-calls config file here.
See the full data file here.
{
"globalConfig": {...},
"attributes": {...},
"entities": {...},
"relations": { // all relations go here
...,
"communication-channel": { // key for generator in relations, must be unique
"data": [ // files from which to load data
"src/test/resources/1.0.0/phoneCalls/communication-channel.csv"
],
"insert": {
"relation": "communication-channel", // relation type to insert
"players": [
...
{
"role": "past-call", // role that the player plays in the relation
"required": true, // required player - only relations in which this player is present are loaded
"match": {
"type": "call", // relation type of player
"ownerships": [
{
"attribute": "started-at", // attribute type of matching attribute
"column": "call_started_at", // column from which to load values
"listSeparator": "###" // if the player column in the data file is a list of values, TypeDB Loader will split the list with the provided listSeparator and insert len(list) number of players
}
]
}
}
]
}
},
...
},
...
}
TypeDB Loader will check if the attributes you are trying to insert or match on are present in your schema. It will also ensure that all values in your data files adhere to the attribute's value type specified in your schema or try to cast them. If a value cannot be cast, it is not inserted, and the line written out into an error log see logging.
TypeDB Loader will also check if all roles are defined in the specified relations, and that the types of players specified actually play that role. If any of these conditions are not met, you will be told exactly what is incorrect in your config to be able to fix it easily.
See the full phone-calls schema here.
See the full phone-calls config file here.
See the full data file here.
Loading relations relation players, matching on players in playing relation (incl. nested relations)
person sub entity,
...,
plays communication-channel:peer;
call sub relation,
...,
plays communication-channel:past-call;
# This is the new relation-with-relation:
communication-channel sub relation,
relates peer,
relates past-call; # this is a call relation playing past-call
peer_1,peer_2
+81 308 988 7153,+351 515 605 7915
+7 171 898 0853,+57 629 420 5680
...
{
"globalConfig": {...},
"attributes": {...},
"entities": {...},
"relations": { // all relations go here
...,
"communication-channel": { // key for generator in relations, must be unique
"data": [ // files from which to load data
"src/test/resources/1.0.0/phoneCalls/communication-channel-pm.csv"
],
"insert": {
"relation": "communication-channel", // relation type to insert
"players": [
...,
{
"role": "past-call", // role that the player plays in the relation
"required": true, // required player - only relations in which this player is present are loaded
"match": {
"type": "call", // relation type of player
"players": [
{
"role": "caller", // nested role nested player plays in the nested relation
"required": true, // required player - only nested relations in which this player is present are used
"match": {
"type": "person", // entity type of nested player
"ownerships": [
{
"attribute": "phone-number", // attribute type of matching attribute for nested player
"column": "peer_1" // column from which to load values
}
]
}
},
...
]
}
}
]
}
},
...
},
...
}
TypeDB Loader will check if the attributes you are trying to insert or match on are present in your schema. It will also ensure that all values in your data files adhere to the attribute's value type specified in your schema or try to cast them. If a value cannot be cast, it is not inserted, and the line written out into an error log see logging.
TypeDB Loader will also check if all roles are defined in the specified relations, and that the types of players specified actually play that role. If any of these conditions are not met, you will be told exactly what is incorrect in your config to be able to fix it easily.
Note that you can, in principle, go to arbitrary nesting depth as the above "match"->"players"->"match" is recursive...
See the full phone-calls schema here.
See the full phone-calls config file here.
See the full data file here.