# Datatype properties represented as edges? (cross post from GitHub)

**URL:** <https://community.neo4j.com/t/datatype-properties-represented-as-edges-cross-post-from-github/53686>\
**Category:** Linked Data, RDF, Ontology\
**Created:** [March 20, 2022, 12:46pm UTC](https://community.neo4j.com/t/datatype-properties-represented-as-edges-cross-post-from-github/53686 "2022-03-20T12:46:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesus\_barrasa](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jesus_barrasa/32/27513_2.png) [@jesus\_barrasa](https://community.neo4j.com/u/jesus_barrasa)\
**Post date:** [March 20, 2022, 12:46pm UTC](https://community.neo4j.com/t/datatype-properties-represented-as-edges-cross-post-from-github/53686/1 "2022-03-20T12:46:56Z")

</div>

I copied this from [a GitHub issue](https://github.com/neo4j-labs/neosemantics/issues/231) because I thought it could be useful for others.

The question was: _"is there a way to force a literal property to be represented as an edge rather than as a neo4j node property so we can associate metadata to it. This would be something similar to the existing ability to force rdf:type to be represented as an edge rather than a (neo4j) property."_

And the answer:

There is not a way of configuring the `n10s.rdf.import.*` methods to convert literals into relationships but you can do it manually by using `n10s.rdf.stream.*` + `n10s.rdf.create.*`

Let's say you have this Turtle-star fragment:

```auto
@prefix neo4voc: <http://neo4j.org/vocab/sw#> .
@prefix neo4ind: <http://neo4j.org/ind#> .

neo4ind:nsmntx3502 neo4voc:name "n10s" ;
         a neo4voc:Neo4jPlugin ;
         neo4voc:version "3.5.0.2" ;
         neo4voc:releaseDate "03-06-2019" .

<<neo4ind:nsmntx3502 neo4voc:releaseDate "03-06-2019">> neo4voc:hasConfidenceLevel "0.43" .

```

You import it first using:

```auto
call n10s.rdf.import.inline(<...theRDF above...>, "Turtle-star");

```

This first pass stores literal properties as node attributes and the metadata `neo4voc:hasConfidenceLevel` is lost .  
Now we do a second pass on the same data

```auto
call n10s.rdf.stream.inline(<... the RDF above... >, "Turtle-star") 
yield subject, predicate, object, isLiteral, literalType, literalLang, subjectSPO
where subjectSPO is not null and subjectSPO[1] = "http://neo4j.org/vocab/sw#releaseDate"
call n10s.add.relationship.uris(subjectSPO[0], 
                                subjectSPO[1], [{ key: predicate, val: object }], 
                                "http://neo4j.org/ind#" + apoc.text.urlencode(subjectSPO[2])) yield rel
return rel

```

This selects metadata on a given predicate (`releaseDate` in this case, but you could change that to apply to all for example), and creates a node out of the literal value (urlencode for valid uri generation: `"http://neo4j.org/ind#" + apoc.text.urlencode(subjectSPO[2])`) and then stores the property as a relationship to the newly created node using the `n10s.add.relationship.uris` method and you can put the metadata on the rel at the same time (`[{ key: predicate, val: object }]`).

The result is that you have the value stored both as an attribute and as a rel with the metadata. If you want to avoid having it stored twice, you can selectively skip it in the `n10s.rdf.import.` method using predicate exclusion (adding `predicateExclusionList : ["http://neo4j.org/vocab/sw#releaseDate"]` to the params). [See manual](https://neo4j.com/labs/neosemantics/4.0/import/#filtering-triples-by-predicate).

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/b/e/bef7a97eb6a0624ed054b3186a20f45c69de77d1.png)

Hope this helps.

JB
