Replies: 6 comments
-
Hi @ubmarco yeah this is indeed a known issue we haven't fixed yet. thanks for pointing it out! Will get this fixed as soon as we can. Meanwhile let me try to gather some feedback on this feature here: is your use case relying on the multiplicity constraint? If so, is limiting the constraint as either one or many good enough? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @ray6080, thanks for the feedback. For my use case, the existing constraints
are enough for now. But I can certainly think about situations in which more complex constraints make total sense. Another point that I have in mind are CREATE NODE TABLE User(id STRING, PRIMARY KEY (id));
CREATE NODE TABLE Dog(id STRING, PRIMARY KEY (id));
CREATE NODE TABLE City(id STRING, PRIMARY KEY (id));
CREATE REL TABLE GROUP Knows (FROM User To City, FROM Dog to City, MANY_MANY); it means I cannot reuse a relationship label in case the multiplicity differs. It would be good if I can specify the multiplicity per relation, e.g. CREATE NODE TABLE User(id STRING, PRIMARY KEY (id));
CREATE NODE TABLE Dog(id STRING, PRIMARY KEY (id));
CREATE NODE TABLE City(id STRING, PRIMARY KEY (id));
CREATE REL TABLE GROUP Knows (FROM User To City, MANY_MANY, FROM Dog to City, MANY_ONE); So a User may know many cities but a Dog can only know one. |
Beta Was this translation helpful? Give feedback.
-
A bit unrelated, but here is a question towards the usage of Cypher for DDL. The Kuzu DDL seems not to be not part of the OpenCypher9 specification. Is this a custom language addition to Cypher? Just wondering whether there are standardized ideas around this topic. I see there is also the |
Beta Was this translation helpful? Give feedback.
-
Hi @ubmarco , sorry for the late reply. It's great we can gather your feedback on this and thanks for your suggestions!
Yeah, this is indeed one limitation of rel table group now. What you suggest definitely can be an option to support. But I feel it's hard to keep the syntax succinct while allowing the semantic expression to be more flexible. As pointed out in your other comment, maybe defining the
Yes, DDL statements are not part of the openCypher standard, instead customized in Kuzu. Here is some brief explanation behind the motivation if you're interested.
This is a good idea. Indeed we had discussions within the team to rework the multiplicity check as a part of the more generic ( |
Beta Was this translation helpful? Give feedback.
-
I would certainly use constraints and multiplicity checks. For me constraint can be split into 2 categories:
I work in an environment in which data is basically schemaless as I don't know the structure of it. A node just links to itself. Then on the node I have a MAP(STRING, STRING) to define properties for the nodes. I could make very good use of a flexible constraint checker on fields and links on already imported data. In the RDF world, SHACL exists to do that and @prrao87 and Paco Nathan wrote a blog post about how to use it with Kuzu that I eagerly consumed. Now I personally must say that RDF tooling is not good as it should be and with our amount of data, |
Beta Was this translation helpful? Give feedback.
-
Hi @ubmarco thanks for providing more details on your use cases and thoughts. Yeah supporting more flexible constraint checks are very appealing to me, and constraints inside databases should be more performant and graceful compared to application level checks.
This is an interesting scenario, not sure how the syntax would be, or maybe it should be combined with UDF 🤔. But it actually looks like a quite fancy feature to me, which requires some flexible and efficient CHECK constraint support if it's done automatically on every data change. Let me bring this up in the team, meanwhile we'll open an issue on this as a feature to gather more community feedback. We can start with basic ones, like non null, positive value, in/out degree checks, etc, though it's hard to promise a timeline for this, as the team is small and everyone is current busy with some important features right now. 😅 |
Beta Was this translation helpful? Give feedback.
-
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:
This is the result of the last
![image](https://private-user-images.githubusercontent.com/839934/372842918-6121925c-bec8-41fa-a57b-6fd4f36569d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MDQ5NTgsIm5iZiI6MTczOTYwNDY1OCwicGF0aCI6Ii84Mzk5MzQvMzcyODQyOTE4LTYxMjE5MjVjLWJlYzgtNDFmYS1hNTdiLTZmZDRmMzY1NjlkOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQwNzMwNThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZTljMjQ3MWZhYzYzODQ1ZjI4MjI4MGQ2YTA2OWMzYzIzZmE1YjZiMmU3NzQ0MzJmMjIzMDliOWVjNGE3MDA2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.LvLfvJSFtRp3U4n1kvA0ys3Gwxu1G50npdg8vibZHvg)
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
Run the queries
Kuzu should complain about the relation
user2 to city1
anduser1 to city2
as it violates the constraint.Beta Was this translation helpful? Give feedback.
All reactions