vaticle / typedb-docs

TypeDB Documentation
25 stars 72 forks source link

undefine relation code snippet does not actually do as described #524

Closed JonThom closed 3 years ago

JonThom commented 3 years ago

Description

The code snippet provided in the example of undefining a relation does not undefine the association of its roles with the relation as well as the association of the role players with the roles as explained in the surrounding text.

Location of Content

https://docs.vaticle.com/docs/schema/concepts#undefine-a-relation

Expected Content

A query to undefine role and roleplayer associations with relation

Actual Content

undefine rule people-speak-the-same-language;

lolski commented 3 years ago

@jmsfltchr Can you check this issue?

jmsfltchr commented 3 years ago

I followed the link above, and the description in the docs is as stated, and that is the desirable behaviour.

The example in the docs is: undefine fluency sub relation;. We want to see if undefining this relation undefines the roles played by its role-players. I have tried it in TypeDB 2.1.1 and everything seems to work as per the docs (see my exploration in the console below). I don't understand how the snippet undefine rule people-speak-the-same-language; is relevant, was this content in this section in the docs previously? That snippet is for undefining a rule and so is not relevant to this section. @JonThom please do clarify if I've missed something, for now I'll close the issue unless you let us know otherwise!

> database create test
Database 'test' created
> transaction test schema write
test::schema::write> define fluency sub relation, relates speaker, relates language;
                     person sub entity, plays fluency:speaker;
                     language sub attribute, value string, plays fluency:language;

Concepts have been defined
test::schema::write> commit
Transaction changes committed
> transaction test schema write
test::schema::write> match person plays $role;

{ $role type fluency:speaker sub relation:role; }
answers: 1, duration: 419 ms
test::schema::write> match language plays $role;

{ $role type fluency:language sub relation:role; }
answers: 1, duration: 20 ms
test::schema::write> undefine fluency sub relation;

Concepts have been undefined
test::schema::write> match person plays $role;

answers: 0, duration: 8 ms
test::schema::write> match language plays $role;

answers: 0, duration: 6 ms
test::schema::write> commit
Transaction changes committed
> transaction test schema read
test::schema::read> match person plays $role;

answers: 0, duration: 15 ms
test::schema::read> match language plays $role;

answers: 0, duration: 11 ms
test::schema::read> match $relation sub relation;

{ $relation type relation sub thing; }
answers: 1, duration: 29 ms
test::schema::read> exit
JonThom commented 3 years ago

Hi, the undefine rule people-speak-the-same-language; was previously part of the code snippet. I see it is gone now.

Still, while the code snippet now presumably undefines the relation as desired, the explanatory text should be amended. Here is the current text:

Given the dependent nature of relations, before undefining the relation itself, we must first undefine the association of its roles with the relation as well as the association of the role players with the roles. Given an employment relation, we would undefine it as shown below.

It seems the whole first sentence could be deleted, leaving

Given an employment relation, we would undefine it as shown below.

jmsfltchr commented 3 years ago

Yes you're right! It doesn't actually say as stated at the top of this issue. I'll fix it now.

jmsfltchr commented 3 years ago

Fix in progress here: https://github.com/vaticle/docs/pull/525