Use the graph-db for Meta Data and Regular Data and validations lists

41 views
Skip to first unread message

Koen

unread,
Aug 30, 2012, 10:10:49 AM8/30/12
to ne...@googlegroups.com
Hi, i have some kind of a design question... besides the regular data /relations i will put into the  graph   i would also would  like to use the same approach for the meta data that is used to generate forms and validate field inputs on these forms...

For example :     i will have a node of a certain type .. lets say a "user" ..

This user has some attributes... lets say   "name" and "city"

The web application shows a form where both "name" and "cit"y are fields on the "user" form

The "city" field is validated against a list of valid city codes.

The form shows the attributes for the "user" object. First the name than the city

So in my graph database i will have a lot of users-nodes all of them with name and city specified as attributes.

question : is it common sense / practice to make a seperate graph tree where i have a node called "user" which is related to nodes for "name" and "city".  These nodes can contain attributes defining their validation charfacteristics and position on a form
The "city" node will point to a whole bunch of nodes that have a their name the name of a city...    

So my web application has to dynamically build a web page with a "user" form and put those 2 attributes on ..   and when the user selects the "city" a list is presented with all "cities" but actually this list is a lookup of all nodes releated to my city
attribute node (the meta data)

On some other parts of the web application i also might point to "city" nodes for othe reasons ..

I hope my example is somewhat clear ...    would this be a good way of working  ?   to use some nodes both for describing your data model , your validation lists  etc ?

What would be the most appropriate way to build for example this "city" validation list on runtimer in the users browser when he opens the selector box ?

many tahnks for your thoughts 

reg Koen



Niels Hoogeveen

unread,
Aug 30, 2012, 12:48:41 PM8/30/12
to ne...@googlegroups.com
Hi Koen.
 
In multispective.com, we do exactly what you describe. Our software is not open source, but you can of course reimplement some of the ideas we have worked out.
 
Niels

Christophe Willemsen

unread,
Aug 30, 2012, 4:09:45 PM8/30/12
to ne...@googlegroups.com
Hi Koen,

Well I would not set the *city* as an attribute to a node but rather as a relation ( let's say *comes_from* ).

I don't know which technology you use but I'll explain what I would do when working with the ReST API.

1. When showing the form, the list of the cities is built from the lookup of all your city nodes in the db.
2. The html attributes of the select options will be the *city name* and the *city node uri*
3. So when saving your user, you save the user node and his attributes ( name, email, ...) and then you create a relationship to the *city node uri*

When you want to retrieve the user information, you have the city available as an outgoing relationship, so you have to do some lazy loading by fetching the related city node.

If you want to retrieve all the users that come from a certain city, you can do a query on the city node and match all the *comes_from* incoming relationships

This way, you can use your city for other implementations in your app ( btw this is a simpe ManyToOne relation the sql way )

You can also index the relationships by grouping them by cities for retrieving all the users that come from a certain city, so you don't have to first retrieve the city and then matching the incoming relationships but directly querying the index.

Hope I'm clear with the explanation.

Cheers

Christophe

Koen

unread,
Aug 30, 2012, 4:25:23 PM8/30/12
to ne...@googlegroups.com
thanks all!

@michiel - thanks .. interesting site / project ! send you an email with some qs
@christophe - thanks .. yes this is what i mean and based on your input i somewhat refined my model ..    i want also to have "meta data" on the objects in the same graphd so that i can dynamically build the forms etc but looking at your remarks this seems  like common sense..


reg koen

Op donderdag 30 augustus 2012 16:10:49 UTC+2 schreef Koen het volgende:

Koen

unread,
Aug 30, 2012, 4:36:12 PM8/30/12
to ne...@googlegroups.com
maybe two other question .. ...

all my city nodes will have a "name" , "longitude" and "lattitude" coordinates as attributes with values..

based on a certain radius in km (kilometer) i want to build a list of nodes that are within this radius based on their coordinates with a certain node as the middlepoint.

and then i will connect the user to these nodes

are there any common usable  implementations for such algorithms (the calculation part)?


same question for federated identity / access management .. i want my users to login with either their   facebook, google, twitter, yahoo , linkedin or microsoft account .. i do not wanna keep track of the credentials for users myself ...     

are there any common usable implementations of such integration ?  What protocols are used ? openid / oauth / saml ?

Would this mean that i have to use some framework such as spring data and would this give me an advantage maybe also related to my other questions ?



thanks and sorry for my novice questions ...


reg koen






Op donderdag 30 augustus 2012 16:10:49 UTC+2 schreef Koen het volgende:
Hi, i have some kind of a design question... besides the regular data /relations i will put into the  graph   i would also would  like to use the same approach for the meta data that is used to generate forms and validate field inputs on these forms...

Christophe Willemsen

unread,
Aug 30, 2012, 4:47:22 PM8/30/12
to ne...@googlegroups.com
1. You can have two indexes, one for lats, and one for longs. Then you can query the index to search users within a certain lat and certain long.

Regarding the algortihm, google is your best friend http://stackoverflow.com/questions/5031268/algorithm-to-find-all-latitude-longitude-locations-within-a-certain-distance-fro

2. It's depending on the technology you use, PHP/Java,... but in the db it remains the same. There are some services that offers multi protocols logins like http://janrain.com/products/engage/ 

Using a framework is an advantage, but it requires also time to learn.

Axel Morgner

unread,
Aug 30, 2012, 6:05:51 PM8/30/12
to ne...@googlegroups.com
Koen,

if you don't mind using Java, you can as well use the Neo4j spatial plugin. I blogged about it here: http://structr.org/blog/distance-queries-with-neo4j-spatial

The code there is somewhat taken from the open source project "structr" where the spatial plugin is integrated into the search.

Greetings
Axel
--
 
 


--

Axel Morgner · ax...@morgner.de · @amorgner

c/o Morgner UG · Hanauer Landstr. 291a · 60314 Frankfurt · Germany
phone: +49 151 40522060 · skype: axel.morgner

structr - Open Source CMS and Web Framework based on Neo4j: http://structr.org
structr Mailing List and Forum: https://groups.google.com/forum/#!forum/structr
Graph Database Usergroup "graphdb-frankfurt", sponsored by Neo4j: http://www.meetup.com/graphdb-frankfurt
Das Sport-Sharing-Netzwerk des Deutschen Olympischen Sportbundes (DOSB): https://splink.de


Koen

unread,
Sep 1, 2012, 1:29:18 AM9/1/12
to ne...@googlegroups.com
hi, thanks all !!  this will definitely help me to workout my algrithms !!


reg koen

Op donderdag 30 augustus 2012 16:10:49 UTC+2 schreef Koen het volgende:
Hi, i have some kind of a design question... besides the regular data /relations i will put into the  graph   i would also would  like to use the same approach for the meta data that is used to generate forms and validate field inputs on these forms...
Reply all
Reply to author
Forward
0 new messages