0

When I create two nodes and then make a relation between them as:

CREATE(cc:CreditCard{id:"5001",number:"1234567890",cvv:"888",expiry:"02/17"})

then

CREATE (e:Customer{id:"1001",name:"Abc",dob:"01/10/1982"})

and then

MATCH (e:Customer),(cc:CreditCard) CREATE(e)-[r:Shop]->(cc)

the following error comes:

This query builds a cartesian product between disconnected patterns. If a part of a query contains multiple disconnected patterns, this will build a cartesian product between all those parts. This may produce a large amount of data and slow down query processing.

While occasionally intended, it may often be possible to reformulate the query that avoids the use of this cross product, perhaps by adding a relationship between the different parts or by using OPTIONAL MATCH

Where am I going wrong?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Pranav
  • 107
  • 2
  • 11
  • That's not an error, it's a warning. You are linking every `Customer` to every `CreditCard`, not linking only the two nodes you just created. – jonrsharpe Jun 03 '16 at 06:51
  • @jonrsharpe, I have a single customer node and two creditcard nodes with each card having a different expiry date. How can I create a relation between my customer node and one of the CreditCard nodes? – Pranav Jun 03 '16 at 07:16
  • By *being specific*, e.g. `MATCH (e:Customer { id: "1001" }), ...` or using a `WHERE c.id = "1001"` – jonrsharpe Jun 03 '16 at 07:17
  • @jonrsharpe I am using this query and still getting the same warning `match (e:Customer{id:"1001"}),(cc:CreditCard {expiry:"02/17"}) create(e)-[r:DoShop]->(cc)` – Pranav Jun 03 '16 at 07:27
  • **Again**, it's just a *warning*. You're still doing a query that *could* be a Cartesian product because those attributes aren't constrained. Also more than one credit card can have the same expiry date. – jonrsharpe Jun 03 '16 at 07:36

0 Answers0