I would create a model with nodes representing the following entities:
Student
Library
Publisher
Book
BookClub
BookInstance - a copy of a specific book in a specific library (a library
can many of these)
Membership - the fact that a Student is a member of a BookClub during a time
period
Lend - the fact that a Student (through his/her membership in a book club)
has borrowed a specific BookInstance

BookInstance would have "start date" and "end date" properties (integer
representation of the date) denoting the time of the lease.
Membership would also have "start date" and "end date" properties, denoting
the time period the membership is valid.
Lend would also have "start date" and "end date" properties, denoting when
the book was borrowed and when it should be returned.

BookInstance would have relationships to the book it is a copy of and the
library it is located in.
Membership would have relationships to the Student that is a member and the
BookClub the student is a member of.
Lend would have relationships to the BookInstance that was lended and the
Membership used to grant it.

All of the enforcement of the validity of the ranges would be handled by
*your domain code*. I.e. the things such as enforcing that the book isn't
borrowed beyond the lease time or that the student membership is valid
during the time the student borrows a book. Your domain code would be
responsible for creating all nodes representing the entities above, and the
relationships in between them as well as enforcing the restrictions. Your
application code would only be considered with your domain objects, and not
with Nodes and Relationships.

For being able to answer questions about which activities have occurred in a
specific time range one or several Timelines[1] could be used. Depending on
what kind of queries you want to optimize for you could have a number of
Timelines. If the most common query is to find all books that have been
lended then a global timeline for all Lend nodes would suffice, but if it's
more common to be interested in what books are lended from a certain library
each library might have its own Timeline for Lends. Then there could be
Timelines for Memberships and BookInstances (= leases) as well, if those are
interesting to query for in ranges.
The Nodes would be inserted in the Timeline at both their start date and end
date, since both of those are significant events (when the book is lended
and when it should be returned). This could either be the same Timeline, or
two separate timelines depending on what queries you would do.

For optimizing the check to see if a book is in the library or not you could
either add a "Current Lend" relationship to the currently active Lend, that
would be removed when the book is returned. Or you could have a "lended
until" property on the BookInstance node that you also
update continuously every time the status of the book changes.

Happy Hacking,
Tobias

[1]
http://components.neo4j.org/neo4j-index/apidocs/org/neo4j/index/timeline/TimelineIndex.html

On Wed, Apr 7, 2010 at 8:26 AM, suryadev vasudev <suryadev.vasu...@gmail.com
> wrote:

> We are exploring Neo4J for a resource management application.
> Imagine 10K students borrowing from 80 libraries. Each library has 3
> million
> books. One student can borrow 1 or more books from each library for a range
> of days. We say the borrower can borrow on day D12 and can self declare the
> date of return D22 for example. These days are called start borrowing date
> and end borrowing date
> The libraries themselves lease books from 2000 publishers. Each book has a
> start leasing date and end leasing date.
> The student has to be a member of a book club to borrow books. She will
> have
> a start membership date and end membership date.
> A student can reserve a book called start reservation date and optional end
> reservation date.
> A book can be borrowed for a date range as long as it is not reserved.
> Publishers have to register themselves with libraries called Start
> registering date and end registering date
> In Neo4J, we created Library, Book-Club, Publisher, Student and Books. We
> are finding it difficult to implement the time variance. The business
> requirements are:-
> 1. The book publisher can lease books till his end registering date
> 2. Publisher can specify lease start date and end date for each book
> 3. Do not lend beyond end leasing date
> 4. Do not lend beyond end membership date
> 5. Query Student-book relationships (What books were borrowed/reserved, who
> was the publisher, what was the book club) for a given date range
>
> How do we model the date in Neo4J?
> Regards
> SDev
> _______________________________________________
> Neo mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Tobias Ivarsson <tobias.ivars...@neotechnology.com>
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to