How can I store references to Java objects in Neo4j?
Neo4j basically stores primitives like integers and strings. See the full reference on what can be stored in the apidocs for setProperty.
I managed to store objects into neo4j by first marshaling them to an XML (I'm using Xstream for that) and then unmarshaling when querying.
Related
I have a requirement to store primitive arrays like long[] for every node.
I have two ways to implement this. One is to join arrays to String like 1, 2, 3 and to store it in Mysql database and to split the string when reading. Another is to store arrays in Neo4j directly.
I wonder which is more efficient, and how Neo4j store arrays, and is there any other better way to store arrays.
There are pros and cons to both methods.
Storing the arrays as a string in a MySQL database has the advantage of being able to query the data more easily.
However, it takes more time to split the string when reading the data, and there is a risk of data corruption if the string is not formatted correctly.
Storing the arrays directly in Neo4j has the advantage of being faster to read, but it is more difficult to query the data.
I wonder which is more efficient, and how Neo4j store arrays, and is
there any other better way to store arrays:
And Neo4j stores arrays as a list of values.
There is no definitive answer to this question as it depends on the specific use case. However, some possible methods for storing arrays in Neo4j include using a relationship for each array element, serializing the array into a string, or using a third-party library.
1.Can Neo4j store RDF directly? we understand it can import RDF and export RDF but how is the data stored internally.
We also understand in Neo4j we can create property graphs and make it as a KG using APOC procedures and algorithms available,is that the case or are we missing anything?
2. We would like to understand, how an entity will be tagged against an ontology in Neo4j KG implementation.
You can import RDF data into Neo4j, however it will not be exactly in that format. Using Neosemantics, the triples will be converted into a property graph.
Neosematics can reconvert the property graph data back into triples should that be required.
I am trying to understand Realm.
https://academy.realm.io/posts/jp-simard-realm-core-database-engine/
I am trying to understand what does the speaker mean
We are essentially building a tree what this results should look like
I think he meant that the Realm will read all objects with name and fulltime properties but not any other properties and then checks if the name is Jack and fulltime is true. Is realm iterating through all objects?
I think he meant that the Realm will read all objects with name and fulltime properties but not any other properties and then checks if the name is Jack and fulltime is true.
Not exactly. Realm get only objects that conform to filter queries.
Is realm iterating through all objects?
You can read in Realm docs about queries that:
All queries (including queries and property access) are lazy in Realm. Data is only read when the properties are accessed.
So, Realm return only (i believe) Results<Employee> that contains filtered objects, but technically read them from realm-db only in moment when you try to access them.
Is it possible to store an object in a field with Cypher so that the node will return some fields as
field.prop.array[0].prop1
field.prop.array[0].prop2
field.prop.array[1].prop1
field.prop2.prop3.prop4
and if so: what's the query to do it? (I've been able to store only 1 level deep objects)
In Neo4j property values can be primitives, Strings or arrays of them, see http://docs.neo4j.org/chunked/stable/graphdb-neo4j-properties.html.
To build up more nested structures you should make them explicit in the graph. A nested property might become a node that connected to the originating node.
I'm trying to convert an XML document into a dataset that I can import into a database (like SQLite or MySQL) that I can query from.
It's an XML file that holds most of the stuff in attributes. This is part of a Rails project so I'm very inclined to use Ruby (and that's the language I'm most comfortable with at the moment).
I'm not sure how to go about doing that and I'd welcome both high-level and low-level contributions.
xmlsimple can convert your xml into a Ruby object (or nested object) which you can then look over and do whatever you like with. Makes working XML in Ruby really easy. As Jim says though depends on your XML complexity and your needs.
There are three basic approaches:
Use ruby's xml stream parsing facilities to process the data with ruby code and write the appropriate rows to the database.
Transform the xml using xslt to a non-XML stream format and feed that into a ruby program that updates the database
Transform the xml with xslt into a format acceptable to the bulk-loading tool for whatever database you are using.
Only you can determine the best approach depending on the XML schema complexity and the type of mapping you have to perform to get it into relational format.
It might help if you could post a sample of the XML and the DB schema you have to populate.
Will it load model data? If you're on *nix take a look at libxml-ruby. =)
With it you can load the XML, and iteration through the nodes you can create your AR objects.
You can have a look at the XMLMapping gem. It lets you define different classes depending upon the structure of your XML. Now you can create objects from those classes.
Now you will have to write some module which actually converts these XMLMapping objects into ActiveRecord objects. Once those are converted to AR objects you can simply call save to save those objects into the corresponding tables.
It is a long solution but it will let you create objects out of your XML without iterating over it. XMLMapping will do it for you.
Have you considered loading the data into an XML database?
Without knowing what the structure of the data is, I have no idea what the benefits of an RDBMS over an XML DB are.