{"id":15994079,"url":"https://github.com/jexp/neo4j-constraints","last_synced_at":"2025-04-05T00:15:28.979Z","repository":{"id":21715902,"uuid":"25037451","full_name":"jexp/neo4j-constraints","owner":"jexp","description":"Optional Schema Constraints for Neo4j using Neo4j-Shell and a TransactionEventHandler","archived":false,"fork":false,"pushed_at":"2014-10-10T21:05:08.000Z","size":139,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T08:30:40.813Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jexp.png","metadata":{"files":{"readme":"readme.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-10T13:48:15.000Z","updated_at":"2019-07-15T20:45:22.000Z","dependencies_parsed_at":"2022-08-18T06:22:19.526Z","dependency_job_id":null,"html_url":"https://github.com/jexp/neo4j-constraints","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jexp%2Fneo4j-constraints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jexp%2Fneo4j-constraints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jexp%2Fneo4j-constraints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jexp%2Fneo4j-constraints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jexp","download_url":"https://codeload.github.com/jexp/neo4j-constraints/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266567,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T07:05:44.181Z","updated_at":"2025-04-05T00:15:28.962Z","avatar_url":"https://github.com/jexp.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"== Neo4j Plugin for Optional Schema Constraints\n\nThis project is a plugin to Neo4j that allows you to describe constraints as graph patterns with a cardinality. This gives you the ability to enforce an optional schema by describing patterns as rules.\n\n----\n// Many people can work for only one company\nCONSTRAIN (:Person)-[:WORKS_FOR]-\u003e(:Company) TO many : 1\n----\n\nNotes:\n\nThis Neo4j plugin is experimental and in an alpha state. Early adopters should use with caution and test with care on toy-stores only.\n\nDo not use this plugin in a production environment. No warranties are provided whatsoever.\n\nPlease provide feedback and your ideas using GitHub issues.\n\n=== Build \u0026 Install\n\nFollow these directions to build this plugin, install it, and start Neo4j.\n\n[source,shell]\n----\ngit clone https://github.com/jexp/neo4j-constraints.git\ncd neo4j-constraints\nmvn install\ncp target/constraints-2.1-SNAPSHOT.jar /path/to/neo4j-community-2.1.5/plugins\n/path/to/neo4j-community-2.1.5/bin/neo4j restart\n----\n\n=== Usage\n\nThere is a new shell command called `CONSTRAIN`\n\nYou can use this new command in order to _add_ cardinality constraints.\n\nAs an example:\n\n----\n// Many people can work for only one company\nCONSTRAIN (:Person)-[:WORKS_FOR]-\u003e(:Company) TO many : 1\n\n// 1 to 3 people can report to no more than one manager or no manager (in the case of the CEO)\nCONSTRAIN (:Person)-[:REPORTS_TO]-\u003e(:Manager) TO 1..3 : 0..1\n\n// One person can only be married to one other person\nCONSTRAIN (:Person)-[:MARRIED_TO]-(:Person) TO one : one\n----\n\n=== How does it work?\n\nWhen using the Neo4j Shell from command line, you can describe patterns with a cardinality constraint. A transaction-event-handler is then used to enforce these constraints.\n\n==== Where are the constraints stored?\n\nThe constraints are stored in a `graph-property` and propagated across a cluster (in the case you're running Neo4j for High Availability).\n\nThe `TX-Handler` only looks at nodes with the relevant labels and checks the degree for those relationship-types, direction and optionally end-node-labels.\n\nAn exception is thrown if the degree `min` or `max` for one of the two sides of a pattern encounters a violation.\n\n=== Next Steps\n\n* `property-type` constraints for qualified relationships and type properties on nodes\n* Node and relationship property value constraints (formats, min, max, min-length, max-length, defaults?)\n* Have suggestions? Please provide any feedback as a GitHub issue\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjexp%2Fneo4j-constraints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjexp%2Fneo4j-constraints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjexp%2Fneo4j-constraints/lists"}