Database Administrators Asked by JavascriptLoser on January 2, 2022
I am designing a neo4j database which will be primarily be used to store information about people. One of the requirements is that it must be able to store an alias name of a person.
I’m having trouble deciding how I should design my database so that it deals with people that have multiple aliases?
I have two solutions:
alias
. This seems to be overly-complex but makes querying easier than option 1.Which of these, if any, is the correct answer to the problem? Or alternatively, is there a better solution which I am overlooking?
Option 2 is the right way for graph databases, especially if :Alias nodes all point to the :Person node (or whatever label you use to differentiate a person entry from an alias) who has that alias. The :Person node itself can also have an :Alias label, allowing their name property to also be considered when performing queries.
For example, if you had a graph like this:
(:Alias {name:'Joe Shmoe'})-[:ALIAS_FOR]->(joe:Person:Alias {name:'Joe Jackson'})
(:Alias {name:'Joe Anybody'})-[:ALIAS_FOR]->(joe)
(:Alias {name:'Joseph Jones'})-[:ALIAS_FOR]->(joe)
Then you could issue a query with an $alias parameter like:
MATCH (:Alias {name:$alias})-[:ALIAS_FOR*0..1]->(person:Person)
RETURN person
You should have an index on :Alias(name) for quick lookup, this allows lookup of the person for their name or any alias associated with them (remember their :Person node is also an :Alias node, so this will match too).
And if you need to do case insensitive searches, or searches across multiple fields, then you may want to look at leveraging fulltext schema indexes introduced in Neo4j 3.5.x
Answered by InverseFalcon on January 2, 2022
Do you need to capture the type of alias, like, maiden name, birth name (ie maiden name or name before change of gender), nick name, preferred name for correspondence (it is bad to assume people are called by their first name), criminal alias, etc? If so comma separated won't work.
If you have a limited number of categories and know you won't add any, then you could use separate fields. Easier for some purposes but harder for others.
Your option 2 is the "right way" but it makes some queries or data entry forms a bit messier. I would recommend making sure your alias or alias/type combinations are unique.
Answered by haresfur on January 2, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP