How to deal with a person that may have multiple alias names? 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:


Store the persons alias names in a single field, comma separated. This is simple, but makes query-ing difficult.
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 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]-&gt;(joe:Person:Alias {name:'Joe Jackson'})
(:Alias {name:'Joe Anybody'})-[:ALIAS_FOR]-&gt;(joe)
(:Alias {name:'Joseph Jones'})-[:ALIAS_FOR]-&gt;(joe)


Then you could issue a query with an $alias parameter like:

MATCH (:Alias {name:$alias})-[:ALIAS_FOR*0..1]-&gt;(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