0

We are trying to implement Customer oriented details in Graphdb, were with a single query we can fetch the details of a customer such as his address,phone,email etc. We have build it using had address, has email edges..

g.addV('member').property('id','CU10611972').property('CustomerId', 'CU10611972').property('TIN', 'xxxx').property('EntityType', 'Person').property('pk', 'pk')

g.addV('email').property('id','CU10611972E').property('pk', 'pk')

g.addV('primary').property('id','CU10611972EP').property('EmailPreference','Primary').property('EmailType', 'Home').property('EmailAddress', 'SNEHA@GMAIL.COM').property('pk', 'pk')

g.V('CU10611972').addE('has Email').to(g.V('CU10611972E'))

g.V('CU10611972E').addE('has Primary Email').to(g.V('CU10611972EP')

This is how we have build email relation to the customer.. Similarly we have relations with Address and Phone. So right now we are using this command to fetch the json related to this customer for email,

g.V('CU10611972').out('has Email').out('has Primary Email')

And for complete Customer details we are using union for each Vertex, Phone,Emaiul and address..

Could you please suggest if there is an efficient way to query this detail?

Sneha Nair
  • 103
  • 9
  • Is there a reason you decided to use a graph to model this? It seems like a classic fit for traditional SQL modeled as a Customer object with properties. – Noah Stahl Jul 28 '21 at 12:43
  • @NoahStahl : yes, basically we have requirement filled in for having graphdb, to get 365 view of a Customer. Could you please help with this situation ? – Sneha Nair Jul 29 '21 at 04:24
  • This seems like a wrong application of graph modeling to me, far overcomplicating storing the data you show. Either way, it's still not clear what your question is? – Noah Stahl Jul 29 '21 at 11:57
  • Edited the question to remove the uncertainty. Just need an efficient way to query, For example we might have alternate email id in future.. So Anybody should easily be able to query the primary and alternate email id corresponding to a customer – Sneha Nair Aug 01 '21 at 05:59

1 Answers1

0

This comes down really to two things.

  1. General graph data modelling
  2. Things the graph DB you are using does and does not support.

With Gremlin there are a few ways to model this data for a single vertex.

  1. If the database supports it, have a list of names like ['home','mobile'] and use metaproperties to attach a phone number to each.
  2. A lot of the Gremlin implementations I am aware of have chosen not to support meta properties. In these cases you have a couple of options. (a) Have a property for 'Home' and another for 'Mobile'. If either is not known you could either not create that property or give it a value such as "unknown" (b) Use prefixed strings such as ["Home:123456789","Mobile:123456789] and store them in a set or list (multi properties) and access them in Gremlin using the startingWith predicate. Such as g.V(id).properties('phone').hasValue(startingWith('Mobile')).value()
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38