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.
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<http://en.wikipedia.org/wiki/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.
> 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.
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.
On Wednesday, August 15, 2012 8:17:01 PM UTC-5, Michael Hunger wrote:
> 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
> Am 15.08.2012 um 21:33 schrieb Christopher Hydak <chy...@identropy.com<javascript:> > >:
> 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.
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.
> 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
> On Wednesday, August 15, 2012 8:17:01 PM UTC-5, Michael Hunger wrote:
> 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
> Am 15.08.2012 um 21:33 schrieb Christopher Hydak <chy...@identropy.com>:
>> 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.
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.hun...@neopersistence.com> schrieb ----
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
Am 15.08.2012 um 21:33 schrieb Christopher Hydak <chy...@identropy.com>:
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.