1

I have a flight database in the form of csv with date and flight number among other columns.

date                        flight
01-01-2011 12:00                428
02-01-2011 12:00                428
03-01-2011 12:00                428
01-01-2011 12:00                429
02-01-2011 12:00                429
03-01-2011 12:00                429

So, on a particular date and time, multiple flights can be scheduled. I want to import this database in neo4j using cql creating a constraint on combination of date and flight number to be unique. My research says that combination of 2 attributes cant be used to set uniqueness. Is there any way to achieve this?

If I set an index on date, It also creates multiple relationships with other attributes when i just want one relationship.

Anonymous
  • 11
  • 2
  • Possible duplicate of [How to create unique constraint involving multiple properties in Neo4J](http://stackoverflow.com/questions/22498054/how-to-create-unique-constraint-involving-multiple-properties-in-neo4j) – cybersam Aug 05 '16 at 16:55
  • Just use `merge` instead of `create`? – stdob-- Aug 06 '16 at 09:37

1 Answers1

0

As suggested, one should use merge. I was using merge earlier too, but only on the date property. Once i used date and flight together in the merge statement, it solved my problem. Thanks.

CREATE INDEX ON :Flights (date)
MERGE (flights:Flights {date: UPPER(line.`date`),flight_no: TOINT(line.`flight`)} )
Anonymous
  • 11
  • 2