Found that Moqui can work with OrientDB. Being new to both Moqui and graph database, my question is: how to put Vertex and edge in Moqui's entity? I mean, in RDMS, If I want to record different people, I can put some thing like:
<entity entity-name="Person" package-name="person">
<field name="personId" type="id" is-pk="true"/>
<field name="name" type="text-long"/>
If I want to creat vertex of different person in OrientDB, how to write the entity?
And how to creat edge in XML code?
Thank you.
If you use OrientDB through the Entity Facade you can use it only as a simple relational structure in the document database in OrientDB. To use full document, graph, and other Orient functionality you have to use the API directly.
There are still few standards for structures and APIs in document, graph, and other NoSQL databases so the best approach is to use the API of a given database rather than using an abstraction layer like the Entity Facade.
Related
I have been looking into some Entity framework tutorials and I have come across the word Entity Graph. I haven't got a clear idea about this term and its use. Can anyone provide info on this topic like what it is and its use in the context of entity framework?
When instantiated objects are joined together in a relationship they are referred to as
a graph, or an entity graph. The Entity Framework has some important rules about how
graphs are maintained.
Example, if you have a User(Entity) graph that consists of a User with Roles, Features.
When you detach the User
The User will be disconnected from this graph and the releationship references (Graph edges) will be destroyed.
You cannot travel from User to Roles/Features, because the graph edges (releationships) are destroyed.
I recommend you buy the "Programming Entity Framework DbContext" book (author: EF-Queen Julia Lerman) and you will find there a good explanation:
http://shop.oreilly.com/product/0636920022237.do
Google is your best friend here:
See this article for general definition and explanation of graphs
See here for specific information on EF and entity graphs
In Jpa hibernate fetching entities with associtions has always been a question for performance. Lazily loading associations with in a transaction again and again results in n+1 select issues and to avoid such issues JPQL join fetch and Criteria api joins are used. But fetching data with these two also result in Cross join issues means Cross join of all table records are returned to apllication by hibernate. Also altering fetch variable defined in annotaions on entity level is also not a good option for some cases. Hence to solve the above two issues entity graphs has been intoduced. All nodes defined in entity graphs are always eager fetched irrespective of their definition on entity level. These graphs are passed as a hint to queries . By passing graphs as a hint Cross join issues are solved as well as run time alteration of fetch behaviour can take place. For code you can check my github repository :
https://github.com/vaneetkataria/Jpa-Hibernate/blob/master/jdbcToJpaMigration/src/test/java/com/katariasoft/technologies/jpaHibernate/entity/fetch/entitygraph/dynamic/MultiInstructorsDynamicEntityGrpahTests.java
I wanna know how to (if possible) create Java classes which have both the behaviour of:
Orient Document (transactions, queries, crud, traverse)
Orient Graph (properties, fields, vertices, edges, links)
Could You kindly redirect me to the correct issue/discussion or code-examples?
best regs
Every time you work with OrientDB Graph API, you can always accessing to the underlying Document Database API, so you can mix usage of both.
If you create a Java class and the DB is a Graph DB you can do/will have what you posted above.
I mean:
Your class will have properties, fields, vertices, edges, link ... ,
but you will can do queries (also using traverse), crud , transactions ...
With Graph API transaction begins automatically, with Document API is explicit by using the begin() method. With Graphs you can change the consistency level.
Basically Graph API is able to support all models in just one Multi - Model.
I attached some examples.
Hope it helps.
I am developing a SPA using Angular-Breeze-WebAPI-EntityFramework.
Now Breeze uses the Entity Framework metadata information to create it's own Breeze models. We use this in our application for Breeze validation.
So far, it's all been nice and easy. Now we are having to create a search page (say for querying customers). The search can be by Customer.Name or by Product.Id (which would return a list of customers who have bought that product). The result is a ng-repeater, which displays Customer.Name, Order.LastPlaced etc.
if you are getting confused by the tables and columns, forget that. What I am only trying to get to is that, both the search object and the result object are not 1:1 with Entity tables (or objects). So obviously I feel the need to create a custom object (one for the search and one for the results). My question primarily is where and how do I create that object?
If I create it at the data layer, Breeze would have no idea of the metadata for each of the properties (since it uses EF for that).
I obviously can't create just a JavaScript object, since I will have to query the database (using EF) to search and populate the object.
So where does one create such a custom object (traversing multiple tables) such that Breeze still can figure out the metadata and perform validation and such when the need arises?
Thank you all.
You can create metadata on the client for types that the server either doesn't know about or doesn't have the schema for. See http://www.breezejs.com/documentation/metadata-by-hand.
I'm starting to work with graph databases, and in my team we've started modeling a graph for our software. The problem comes when we try to "document" the model, to see the structure of our database. With SQL databases you only have to look at the SQL schema.
We've spent some time reading neo4j blogs and documentation, but we've seen that the usual way to show how a graph works is with a minimal graph showing some sample data (Random samples: sample1, sample2, etc). That's great for educational purposes, but we'd love to be able to do it in a little more formal way. We'd like to set what kind of node can relate with another one, and with what kind of relationship, that kind of stuff.
Using Spring you can wrap the graph with classes, but it's very specific to Java and OO model, and we're working with Erlang. We're looking for some kind of formal language (SQL Schema equivalent), or a E-R model equivalent, or something like that.
One way to do this is to put the "meta-model" of your graph (a type network) in the graph as well and then connect the instances (nodes) to their meta-model-type. So you can visualize the meta-model using the graph visualization and at the same time use the meta-model to enforce additional constraints (by storing constraint information in the meta-model and using that when the actual model is updated) and also use the type-nodes of the meta-model to quickly access all "instance"-nodes of this type.
What is the domain you want to model?
A quick idea - could you use a subset of UML? Graph modeling seems to be closer to the domain, so maybe that's reasonable.
What we do is a generalization of the "example data" approach, where we include cardinality on each side of a relationship, as well as type and direction. I also often include a node "type" in the diagram (or some other specification of it's role/relation to domain models) instead of example data, and of course note the expected properties, their types, and whether they are optional. It's less than formal, but has served well so far.
I'm working with a large hierarchical data set in sql server - modelled using the standard "EntityID, ParentID" kind of approach. There are about 25,000 nodes in the whole tree.
I often need to access subtrees of the tree, and then access related data that hangs off the nodes of the subtree. I built a data access layer a few years ago based on table-valued functions, using recursive queries to fetch an arbitrary subtree, given the root node of the subtree.
I'm thinking of using Entity Framework, but I can't see how to query hierarchical data like
this. AFAIK there is no recursive querying in Linq, and I can't expose a TVF in my entity data model.
Is the only solution to keep using stored procs? Has anyone else solved this?
Clarification: By 25,000 nodes in the tree I'm referring to the size of the hierarchical dataset, not to anything to do with objects or the Entity Framework.
It may the best to use a pattern called "Nested Set", which allows you to get an arbitrary subtree within one query. This is especially useful if the nodes aren't manipulated very often: Managing hierarchical data in MySQL.
In a perfect world the entity framework would provide possibilities to save and query data using this data pattern.
Everything IS possible with Entity Framework but you have to hack and slash your way in to it. The database I am currently working against has too many "holder tables" since Points for instance is shared with both teams and users. Both users and teams can also have a blog.
When you say 25 000 nodes do you mean navigational properties? If so I think it could be tricky to get the data access in place. It's not hard to navigate, search etc with entity framework but I tend to model on paper then create the database based on how I want to navigate while using entity framework. Sounds like you don't have that option.
Thanks for these suggestions.
I'm beginning to realise that the answer is to remodel the data in the database - either along the lines of nested sets as Georg suggests, or maybe a transitive closure table, which I've just come across.
That way, I'm hoping to get two key benefits:
a) faster querying aginst arbitrary subtrees
b) a data model which no longer requires recursive querying - so perhaps bringing it within easy reach of the Entity Framework!
It's always amazing how so often the right answer to a difficult problem is not to answer it, but to do something else instead!