0

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:

  1. Store the persons alias names in a single field, comma separated. This is simple, but makes query-ing difficult.
  2. Store a persons alias name in a separate table/entity called 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 if it's relational data, but use whatever is easier to maintain. – Randolph West Jul 11 '18 at 2:57
0

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

0

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.

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.