Islandora / documentation

Contains islandora's documentation and main issue queue.
MIT License
104 stars 71 forks source link

Modeling list of relations in RDF and Drupal #729

Closed Natkeeran closed 6 years ago

Natkeeran commented 7 years ago

We are modelling relationships between people. For this project, two people can be related by an array of roles or relations. Some are binary relations (Co-religionist, Compatriot, Slave-Master, Teacher-Trainee) and some are familial relations (parent, partner, child, sibling). We want to take advantage of Linked Data and provide inverse relations and transitive relations where appropriate.

As the list of possible type of relations is rather extensive, how best to model this in RDF and Drupal?

Brute force approach would be to list all possible relations as properties to Person content type.

Another option is to define Relation as a class (relation content type: field_relationType, field_person). However, there is no method to map a value of a field to a triple (ex: Person 1 studentOf Person2, where studentOf is a value of a field), thus we won’t be able to take advantage of any reasoning capability (inverse, transitive).

Third options would be provide the relation as a select list and do some custom coding to populate the additional triples!

Thank you for the feedback.

dannylamb commented 7 years ago

I would suggest doing what works best for Drupal in terms of performance and complexity, e.g. make it work sensibly with Views. Then turning on inferencing in the triplestore to fill in the gaps. I wouldn't want to manage bidirectional or transitive relationships manually unless I had a really compelling reason, because I can get the 3-store to do that for me in RDF and I can just write an intelligent query to get at things with SQL.

Sometimes that's not possible and I understand that, but just my $0.02.

ajs6f commented 7 years ago

What @dannylamb said, although I think he might have meant SPARQL, not SQL.

One point to keep in mind: inferencing isn't free (it will make either your indexing or querying run slower, and sometimes both) so add that (performance) to the list of things you'll want to test as you go. It's a completely viable technique, and as Danny says, you will end up doing less work to manage your data in the long run. Just remember to keep an eye on your computers to make sure they don't slack off on the job. :)

Natkeeran commented 7 years ago

@dannylamb @ajs6f Yes, it would be the triplestore that would handle the bidirectional or transitive relationships.

The main question is if there is any alternative to having a long list of properties attached to the content type as fields. Ideally, if there is some magical way to map drupal field value to a rdf property, that would solve our problem. We can possibly do that with custom code.

dannylamb commented 7 years ago

@ajs6f :man_facepalming: You are correct, I meant SPARQL

ajs6f commented 7 years ago

@Natkeeran Do you mean something like a "convention over configuration" deal wherein Drupal fields would automatically map to RDF predicates with some simple out-of-the-box conversion like "default namespace + fieldname" or something?

ajs6f commented 7 years ago

@dannylamb Just wait until you start mixing up your kids.

Natkeeran commented 7 years ago

@ajs6f Not quite.

There are some challenges in expressing relationships in Drupal. For example, there is no easy way to link two fields other than through inline entity. Once expressed as inline entity, it would create a uri (not always needed).

For example, in the following triple, relationTypeX has to be a field in Drupal.
Person A relationTypeX Person B

We can crate a long list of fields with these relations, but from UI point of view, would be better to have them as a select list. We cannot map an RDF property from a select list or field value.

whikloj commented 7 years ago

@Natkeeran what about how we link an Image to a Collection by use of a autocomplete box? Is that a possibility?

whikloj commented 7 years ago

Oh wait, so you want to be able to choose the relationship between the two things. I don't know that Drupal does that, instead you would have different fields for those connections and map those fields to a specific predicate.

This gets to possibly using a more specific Entity for each more specific type of data, so you don't necessarily have all the relationships in a more general Entity

Natkeeran commented 7 years ago

@whikloj

Yes, two bundles can be related by a field (collection - image) and that field mapped to a predicate.

I want to be careful in not conflating the issues. I don't think that collection -> item type of modelling would run into theses issues soon, but more complex data models would.

1) Within a bundle, there is no straightforward way to group/nest/relate two fields other than by building another bundle and including that as an inline entity. For example, relationType - targetPerson.

For this iteration, we are going to add the needed relations as fields to the bundles. Seems like the simplest and no-code solution.

Thank you for the input.

(This ticket can be closed)

ajs6f commented 7 years ago

@Natkeeran (you can close it, or at least you should be able to)

What I'm getting out of this is that we really need something like "mixins" of predicates. I would have used the word "bundle", but since that's been taken… how about "quivers" of predicates?

whikloj commented 7 years ago

@Natkeeran Ohhh wait, maybe I'm just getting this.

So you are okay with mapping one field from Bundle/Item/Etc A and one field from Bundle/Item/Etc B ala

<Collection ID> pcdm:hasMember <Image ID>

But you can't generate a mapping for two fields in the same Bundle ala

<Image Photographer> ex:usesCamera <Camera field>

and that is what you want to do?

Natkeeran commented 7 years ago

@whikloj Yes that would be nice. But, I realize it is not supported by Drupal.

Natkeeran commented 6 years ago

We are currently handling this issue by custom code in jsonld. Not pretty, but works for now!.