kuzu
kuzu copied to clipboard
Bug: Relationship multiplicity not working
Kùzu version
v0.6.0
What operating system are you using?
Arch Linux x64
What happened?
I feel the relationship constraints are not working as documented in https://docs.kuzudb.com/cypher/data-definition/create-table/#relationship-multiplicities.
This Cypher executes successfully on an empty in-memory DB:
CREATE NODE TABLE User(id STRING, PRIMARY KEY (id));
CREATE NODE TABLE City(id STRING, PRIMARY KEY (id));
CREATE REL TABLE LivesIn(FROM User TO City, ONE_ONE);
CREATE (u:User { id: 'user1' });
CREATE (u:User { id: 'user2' });
CREATE (c:City { id: 'city1' });
CREATE (c:City { id: 'city2' });
MATCH (u:User), (c:City) WHERE u.id = 'user1' AND c.id = 'city1' CREATE (u)-[e:LivesIn]->(c);
MATCH (u:User), (c:City) WHERE u.id = 'user2' AND c.id = 'city1' CREATE (u)-[e:LivesIn]->(c);
MATCH (u:User), (c:City) WHERE u.id = 'user1' AND c.id = 'city2' CREATE (u)-[e:LivesIn]->(c);
MATCH (u)-[e]->(c) RETURN *;
This is the result of the last MATCH
statement in the Explorer:
1 User Lives in 2 Cities while 1 City has 2 LivesIn Users. The point of stating ONE_ONE
means that the relation must be 1 in both directions.
Is this a bug or am I doing something wrong?
Are there known steps to reproduce?
Start Explorer with an empty DB
docker run -p 8000:8000 --rm -e KUZU_IN_MEMORY=true kuzudb/explorer:latest
Run the queries
```cypher
CREATE NODE TABLE User(id STRING, PRIMARY KEY (id));
CREATE NODE TABLE City(id STRING, PRIMARY KEY (id));
CREATE REL TABLE LivesIn(FROM User TO City, ONE_ONE);
CREATE (u:User { id: 'user1' });
CREATE (u:User { id: 'user2' });
CREATE (c:City { id: 'city1' });
CREATE (c:City { id: 'city2' });
MATCH (u:User), (c:City) WHERE u.id = 'user1' AND c.id = 'city1' CREATE (u)-[e:LivesIn]->(c);
MATCH (u:User), (c:City) WHERE u.id = 'user2' AND c.id = 'city1' CREATE (u)-[e:LivesIn]->(c);
MATCH (u:User), (c:City) WHERE u.id = 'user1' AND c.id = 'city2' CREATE (u)-[e:LivesIn]->(c);
MATCH (u)-[e]->(c) RETURN *;
Kuzu should complain about the relation user2 to city1
and user1 to city2
as it violates the constraint.