I have three tables, customer, product and subscription.
In dgraph, customer and prodcut tables are nodes with scalar values (e.g., name, sex, addr., etc); subscription will be links/edges/predicate between customers and products. A customer can have multiple subscriptions for the same product, i.e., there can be multiple links/predicate between a given customer and product. The attribute/facets of the link/predicate are different. For instance, subscription start and end dates are possible attributes/facets. These attributes/facets are sort of the key referring the link.
I have some questions to model this:
- Is this the correct way to model these kind of tables ?
- How to create multiple links between two nodes ? I could not add multiple predicates for a given customer and product. Does dgraph support multiple predicates ?
- Can facets on predicate be list of string or int ?
**Answer from Sai (slack) No…current support is only one value. But you can use the index and append to the facet and add multiple facets (like color1=red, color2=orange etc) **
If list[date] or list[str] is allowed on edge uid predicate, then subscription history can be modeled using single link but attribute list instead of multiple links. Of course in this case, the order of list has to be maintained.
Regarding to appending multiple facets (Sai suggestion), how is query performed and how efficient is the query ? Let’s assume that predicate is subscription date, we have date1=2016-01-01, date2=2015-01-01, … daten=2018-01-01. How can I aggregate how many times the customer has subscribed the product between 2016-2018?
Or should I model other way?
All kinds of suggestions are welcome.