-1

here is my scenario. I have a pre-defined data type structure for books. Just take it as an example for the sake of simplicity. The structure looks like the image below. It's a Labeled Property Graph and the information is self-explained. This data type structure is fixed, I cannot change it. I just use it.

DTR Example

When there is 1 book, let's call it Harry Potter, in the system, it might look like below:

DTR 1 book

So, the book has its own property (ID, Name,...) and also contains a field type MandatoryData. By looking at this graph, we can know all information about the book.

The problem happens when I have 2 books in the system, which looks like this:

DTR 2 Books

In this case, there is another book called Graph DB, with those information as highlighted.

The problem of this design is: we don't know which information belong to which book. For example, we cannot distinguish the publishedYear anymore.

My question is: how to solve or avoid this problem? Should I create 1 MandatoryData for each book? Could you propose me any design?

I'm using Neo4j and Cypher. Thank you for your help!

  • 1
    Hi. You said "The problem of this design is: we don't know which information belong to which book. For example, we cannot distinguish the publishedYear anymore." But in the graph model you have nodes and vertexes only. The information in one node does not belong to any other node. If you want any information to actually belong to the node, store it as an attribute in the node. – filiprem Dec 4 '17 at 9:02
2

Should I create 1 MandatoryData for each book?

Yes.

If you cannot get rid of MandatoryData object, you should have one such object per book.

Otherwise I would simplify the model and move any mandatory attributes to the Book object, which will reduce ne04j database size. Modeling relationships which are always 1:1 is a bit silly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.