2010/2/19 Jeremy Day <[email protected]>: > Mattias, > > Could you do something like Student --> Autumn 2009 --> Math A ? You could > then easily also have Teacher --> Autumn 2009 --> Math A. Absolutely, that could definately work as a model. > > Jeremy > > On Fri, Feb 19, 2010 at 6:54 AM, Mattias Persson > <[email protected]>wrote: > >> 2010/2/19 <[email protected]>: >> > Mattias (and everyone) - can you see a way to model multiple >> > relationships of the same type between two nodes? We have few cases >> > where the relationship is essentially the same "type" but might have >> > different properties. Max's "Class/Teacher" scenario is >> > somewhat similar. >> Yes, I've used such models a couple of times and it's a completely >> valid usecase in some scenarios (not any particular comes to mind >> though). >> >> You're suggesting something like: we have a "Math A" class node and >> it'll have relationships to all teachers and students who have >> attended that class? You would then "loose" the information about >> which students have attended a specific class instance (f.ex. autumn >> 2009 or something) with a specific teacher (if you don't store that >> information on every Teacher ----> Class relationship and Student >> ----> Class relationship). Did I understand you correct? >> > >> > >> > >> > Rick >> > >> > >> > >> > -------- Original Message -------- >> > Subject: Re: [Neo] Choosing between a property or a node >> > From: Mattias Persson <[email protected]> >> > Date: Fri, February 19, 2010 4:27 am >> > To: Neo user discussions <[email protected]> >> > I've included some first thoughts on how you could model this. The >> > choice of properties/index vs. relationships is often quite obvious, >> > but is some cases you'll have to try and see which fits best. But >> > neo4j encourages you to create relationships if you're in doubt and >> > it's often better to use more relationships types than fewer, i.e. >> > it's good to be as specific as possible when modelling your graph. >> > 2010/2/19 Max De Marzi Jr. <[email protected]>: >> > > Hello, >> > > >> > > What is the proper way to handle things that have only a few choices >> > like: >> > > >> > > gender (male/female/unknown) >> > > status (active, inactive, purged) >> > > race(10 choices + other) >> > > etc. >> > > >> > > As properties of a Person node, or as nodes that link to the Person >> > node? >> > > >> > > Pros or Cons of each method? >> > It depends on how you're querying the data... gender, status and race >> > could probably be modelled using properties (and maybe indexed with >> > IndexService, see [1]http://components.neo4j.org/neo4j-index/) since >> > you >> > would use them as filters in queries. But if you're planning to do >> > traversals which will bridge persons over to other persons (or other >> > entities) via f.ex. status, then relationships would be handier. >> > > >> > > How about something with instances? >> > > >> > > Student took a Class (twice) once with This teacher, once with >> > Another >> > > Teacher. >> > > >> > > The first time he failed, the second time he got a B. >> > > >> > > Create a StudentClass node with a property of Grade, linked to >> > Teacher? >> > Yes, have each student as a node. Each class instance as a node with >> > TEACHES_IN relationship to teacher (and maybe CLASS_TYPE relationship >> > to what type of class the class instance is). Have a TAKES_CLASS >> > relationship between student and class instance and set grade property >> > on that relationship. >> > > >> > > In order to answer: >> > > >> > > Find all students who took the class. >> > Relationships between student and class. >> > > Find all students who took the class when it was offered in the >> > spring >> > > semester (or taught by This Teacher). >> > Start from either a teacher node (and go to the class instance) or >> > from a class instance. They can be lookup up from and IndexService or >> > something) and get relationships to students from there. >> > > Find all students who got a B >> > If you create nodes for each grade available and create relationships >> > to those grade nodes whenever a student gets a grade. Then it'd be >> > easy to just get that "B" grade node and traverse all its >> > relationships to students. Otherwise you could index the grade >> > property from the ATTEND_CLASS relationships (see above) for the >> > student nodes. >> > > Find all students to got a B in this class? >> > Start from the class and traverse out to all its class instances and >> > students, filtering those who got a B (using the grade property on >> > ATTEND_CLASS relationships). >> > > Find all students to got a B in this class during the spring >> > semester? >> > Same as previous but only traverse those class instances which were >> > offered in spring semester. >> > > Find all students to got a B in this class when This Teacher taught >> > it? >> > Start from either the teacher node or the class node and find the >> > class instance for that class which the teacher has a relationship to. >> > And tou get the students from there. >> > I hope this will help you, >> > Best, >> > Mattias >> > _______________________________________________ >> > Neo mailing list >> > [email protected] >> > [2]https://lists.neo4j.org/mailman/listinfo/user >> > >> > References >> > >> > 1. http://components.neo4j.org/neo4j-index/ >> > 2. https://lists.neo4j.org/mailman/listinfo/user >> > _______________________________________________ >> > Neo mailing list >> > [email protected] >> > https://lists.neo4j.org/mailman/listinfo/user >> > >> >> >> >> -- >> Mattias Persson, [[email protected]] >> Neo Technology, www.neotechnology.com >> _______________________________________________ >> Neo mailing list >> [email protected] >> https://lists.neo4j.org/mailman/listinfo/user >> > _______________________________________________ > Neo mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user >
-- Mattias Persson, [[email protected]] Neo Technology, www.neotechnology.com _______________________________________________ Neo mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

