I have a triple store with RDF triples and I want to export the data to a table where columns represent the predicates. For example, if I have the following triples
:s1 :p1 "v11"
:s1 :p2 "v12"
:s2 :p2 "v22"
:s2 :p3 "v23"
I want it to be as follows
----| p1 | p2 | p3
s1 | v11 | v12 | (null)
s2 | (null) | v22 | v23
This might seems a little odd, as in most cases we need to export the other way but here I want to feed this data into a data mining software.
USE OPTIONAL
If you know the predicates in advance, you can wrap each predicate in OPTIONAL to get all predicates in the same row for all subjects - even if some are missing. Here is an example:
I keep my original answer for reference:
Use UNION (creates separate rows for each predicate)
If you know the predicates in advance, you can use UNION to get all predicates for all subjects - even if some are missing. Here is an example: