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.
When there is 1 book, let's call it Harry Potter , in the system, it might look like below:
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:
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!
UPDATE
From the comments (by @AnhTriet):
Thanks for your suggestion. But I want to have some sort of connection between those books. If we create new MandatoryData, those books will be completely separated. (...) I meant, 2 books should point to some same nodes if they have the same author or published year, right?
After some clarification in the comments, I suggest the creation of a MandatoryData
node for each property in the database. Then you will connect a given book to various MandatoryData
nodes, depending on the number of properties of the book.
This way two books with the same author will be connected to the same MandatoryData node.
Since you cannot change the data model, I strongly recommend you to create a new MandatoryData
node for each new book added to the system.
This way you will be able to get informations about the an specific book with queries like:
// Get the author's name of the book with ID = 1
MATCH (:Book {ID : 1})-->(:MandatoryData)-->(:Author)-->(:Name)-->(v:Value)
RETURN v.value
The model proposed in your question is not viable since has no way to identify the owner of an specific property, as indicated by you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.