Re: [Neo4j] Making the transition from LDAP/RDBMS to Graph

221 views
Skip to first unread message

Nigel Small

unread,
Aug 15, 2012, 5:48:22 PM8/15/12
to ne...@googlegroups.com
Hi Christopher

Neo4j specifically avoids imposing any structure or rules at all onto your data and nodes are deliberately typeless entities. Instead, it becomes solely the responsibility of the application which owns and uses that data store to manage how that content is used (and whether certain fields are mandatory or not).

From a personal point of view, I tend to think more in terms of duck typing when storing data in Neo4j. In your case, this could mean that your application might allow any node with a "FirstName" and "LastName" property to be treated as a person or if a node has one or more outgoing "MANAGES" relationships then it can be seen as a manager.

Hope this helps
Nige


On 15 August 2012 20:33, Christopher Hydak <chy...@identropy.com> wrote:
I'm having some difficulties making the transition from a traditional schema-based database to a graph database and I was hoping that someone here can beat the truth into me.  I am creating a user store, which obviously can have many relationships and attributes. It makes certain sense to use a graphdb for this type of data, but I can't get over how I can enforce required attributes when creating a new person.  I find that I want to create a template graph that is pretty much the same thing as a schema.  Is that even possible in neo4j or am I missing the point?

Here is a sample SQL schema for a person object that I am using.

CREATE TABLE [dbo].[Users](
[UID_Person] [nvarchar](38) NOT NULL,
[FirstName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NULL,
[DepartmentUID] [nvarchar](38) NULL,
[WorkPhone] [nvarchar](15) NULL,
[ManagerUID] [nvarchar](38) NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
[UID_Person] ASC
)

Thanks,
Christopher

--
 
 

Michael Hunger

unread,
Aug 15, 2012, 9:17:01 PM8/15/12
to ne...@googlegroups.com
All your properties except the id are nullable so what do want to enforce?

Which language/deployment ?

Why do you want to enforce the attributes?

Sent from mobile device

Christopher Hydak

unread,
Aug 16, 2012, 8:35:59 AM8/16/12
to ne...@googlegroups.com
Thanks for both of the responses.

Nigel, That does help level-set the idea in my head.   From my legacy SQL point of view, provided I maintain my required fields in my insert statement in the language, Java, I can enforce any structure I want.

Michael, the example I sent you was a small subset of what I really have.  Typically, there are more attributes such as password, that would be a required field in any user store.  Every user must have a password.  So, when I create a person node, I must require a password attribute to be set.

Thanks,
Christopher

Michael Hunger

unread,
Aug 16, 2012, 9:12:38 AM8/16/12
to ne...@googlegroups.com
Christopher,

you would actually do it in your application level code, before creating the nodes and relationships.

What you can do in neo4j is to register a transactioneventhandler which is passed the newly created data before commit and can verify if the creates/updates are valid or roll back the transaction by throwing an exception.

HTH

Michael

--
 
 

Charles Bedon

unread,
Aug 17, 2012, 9:49:57 AM8/17/12
to ne...@googlegroups.com
Hello

You have to take into account these aspects:

1. N4J is schemaless, so a node represeting a "record" may not have the same properties as another node representing the same "type" of element. That's the nature of the db and it's suitable for most use cases.

2. There can't be null property values. You can't set "FirstName" to null, for example. That will raise an IllegalArgumentException.

Try checking your data model constrains at application level, not at db level. Yeah, this can be a downside depending on the point of view.

-------------------------------------
Charles Edward Bedón Cortázar
Network Management, Data Analysis and Free Software http://www.neotropic.co | Follow Neotropic on Twitter
Open Source Network Inventory for the masses!  http://kuwaiba.sourceforge.net | Follow Kuwaiba on Twitter
Linux Registered User #386666


---- Am Wed, 15 Aug 2012 20:17:01 -0500 Michael Hunger <michael...@neopersistence.com> schrieb ----

--
 
 

Reply all
Reply to author
Forward
0 new messages