# 'Remove Constraint' remove all constraints?

**URL:** <https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081>\
**Category:** Support\
**Created:** [June 5, 2021, 3:26am UTC](https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081 "2021-06-05T03:26:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aho](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@aho](https://community.stardog.com/u/aho)\
**Post date:** [June 5, 2021, 3:26am UTC](https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081/1 "2021-06-05T03:26:48Z")

</div>

Will Stardog Studio 'Remove Constraint' remove all constraints? I tried change shacl and failed. It seems to me 'Remove Constraint' does not remove all constraints, or did I make any mistake?

I am using Stardog Studio PC version, server side is stardog 7.6.2.  
I download stardog-tutorials from github. Modify the sample shacl file: shacl/music\_shacl.ttl:

- Add a 'sh:maxLength 100 ' constraint to NameShape. add constraint and load valid.ttl, which is success. Then cleanup: remove data and constraint;
- Then I change Nameshape shacl maxLength to 'sh:maxLength 5 ;'; add constraint and load valid.ttl again, failed, which is expected because maxLength is only 5; Then cleanup: remove constraint;
- Then I change Nameshape shacl maxLength back to 'sh:maxLength 100 ;' add constraint and load valid.ttl again, FAIL, why??? We just prove 100 is a valid constraint in prior step.  
Did I missing anything???

I also did other tests in different order, it seems to me that as long as shacl fail, it will always fail. 'Remove Constraint' can not remove the failed shacl.

Here is the complete nameshape that I changed, the only thing change is add a maxLength;  
:NameShape a sh:Shape ;  
sh:property [  
sh:path :name ;  
sh:minCount 1 ;  
sh:maxLength 100 ; ----\> change back and forth to 5, 100;  
sh:datatype xsd:string  
] .

Here are the detail steps:

1. Goto [GitHub - stardog-union/stardog-tutorials: Data files for the Stardog tutorials](https://github.com/stardog-union/stardog-tutorials) clone

2. create a new database, turn database offline then change properties transaction-\>Serizable; ICV guard mode enabled; turn on database;

3. 'Add Data' Band schema from music/music\_schema.ttl:  
:Band a rdfs:Class ;  
rdfs:label "Band" ;  
rdfs:comment "A music group; that is, is a group of people creating and performing music together." ;  
rdfs:subClassOf :Artist .

4. Add 'sh:maxLength 100 ;' to NameShape to shacl/music\_shacl.ttl; then add constraints;

5. load data shacl/valid.ttl; success, which is expected;

6. Remove data valid.ttl, remove constraint music\_schema.ttl;

7. Modify maxLength to 'sh:maxLength 5 ;' to NameShape to shacl/music\_shacl.ttl; then add constraints;

8. load data shacl/valid.ttl; fail, which is also expected;

9. Remove constraints

10. Modify back 'sh:maxLength 100 ;' to NameShape to shacl/music\_shacl.ttl; then add constraints;

11. load data shacl/valid.ttl; fail. WHY???? We just prove maxLength 100 is perfect fine in prior step.

---

<div class="post-metadata">

**Author:** ![aho](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@aho](https://community.stardog.com/u/aho)\
**Post date:** [June 8, 2021, 11:14am UTC](https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081/2 "2021-06-08T11:14:27Z")

</div>

Hi,

Anyone using Shacl in StarDog? If you want to make Shacl change, what will you do?

- Drop database, then recreate? This will work, but how can this be in Production?

- Import Shacl constraint initially. Then remove and re-import shacl constraints for changes. If you pick this approach, do you have any trouble? I tried this approach and found Shacl constraint can not be completely removed.

- Add Shacl as data initially. Then remove and re-add shacl as data for changes. I tried this approach also, and found Shacl data can not be completely removed.

It seems this issue exist for a while, any solution?

> [@SHACL: icv remove not removing constraints?](https://community.stardog.com/t/shacl-icv-remove-not-removing-constraints/1788):
>
> [UPDATE 2021-06-07: Issue remains in Stardog v. 7.4.0 for removing constraints that involve bnodes. any update on possible fix?] Hi folks, I may be doing something wrong here, but it appears to me that the icv remove command is not fully removing constraints from the database. Am I missing an option in the remove command? Here are my steps and results. I'm running this from the command line to take Studio out of the equation (related post from yesterday). Create new database SHACLTest. L…

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [June 8, 2021, 11:25am UTC](https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081/3 "2021-06-08T11:25:25Z")

</div>

The easiest solution is to add SHACL constraints into a named graph (just as normal RDF data, e.g. with the `data add` command). Then clear that graph, edit your constraints, and re-add to the same graph.

Best,  
Pavel

---

<div class="post-metadata">

**Author:** ![aho](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@aho](https://community.stardog.com/u/aho)\
**Post date:** [June 10, 2021, 12:08pm UTC](https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081/4 "2021-06-10T12:08:40Z")

</div>

Named graph will work. While I still can not completely remove the Shacl through remove data, but since we can edit constraint directly through Stardog Studio, so I can remove all constraint this way. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [June 24, 2021, 12:09pm UTC](https://community.stardog.com/t/remove-constraint-remove-all-constraints/3081/5 "2021-06-24T12:09:34Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
