Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ TypeDB Cloud deployments let you deploy the latest version of the bookstore samp
=== Using TypeDB Console
You can use xref:{page-version}@home::install/console-cli.adoc[TypeDB Console] (minimum version 3.5.0) to load the bookstore dataset from the `typedb-example` repository, published at https://github.com/typedb/typedb-examples/releases.

// TODO: Make this clearer. What address should one use? Is there a default username? How do you set these things up via the CLI?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this one is unfounded, but this is the first step in the Academy. In the chapter index, it says the first step will be setting up a TypeDB server, but we don't actually do that here.

Is there a step missing? Even pointing back to the installation instructions might be helpful.

TypeDB Console ships with a 1-liner to create a database, and load a schema and data file from URL. To create and initialize a new database with the latest bookstore dataset, you can use:

[,bash]
Expand Down
2 changes: 2 additions & 0 deletions academy/modules/ROOT/pages/2-environment-setup/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ In this lesson, we'll set up the environment needed to work through this course.

== Lesson contents

// TODO: Add reference to Lesson 2.2 when it is written.
[cols-2]
--
.xref:{page-version}@academy::2-environment-setup/2.1-sample-deployment.adoc[]
[.clickable]
****
Deploy the sample database and install TypeDB Studio.
****
--
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ match
$book isa paperback, has isbn-13 "9780446310789";
$line isa order-line (order: $order, item: $book);
fetch {
"id": $order.id;
"quantity": $line.quantity;
"id": $order.id,
"quantity": $line.quantity
};
----

Expand Down Expand Up @@ -352,7 +352,7 @@ $book isa paperback, has isbn-13 "9780446310789";
$line isa order-line (order: $order, item: $book);
delivery (deliverer: $courier, delivered: $order, destination: $address);
fetch {
"id": $order.id;
"id": $order.id,
"quantity": $line.quantity,
"name": $courier.name,
"street": $address.street
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Write a query to retrieve _all_ ISBNs of _all_ books in the database.
match
$book isa book;
fetch {
"isbn": $book.isbn
"isbn": [ $book.isbn ]
};
----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ So far, the Insert queries we've seen have only created entirely new entities, r
[,typeql]
----
match
$book isa book, has isbn-13 "9780486282114";
$stock isa stock;
$frankenstein isa book, has $stock, has isbn "9780486282114";
insert
$book has stock 20;
$frankenstein has stock 20;
Comment on lines 148 to +152
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is pointed out later in Data validation, the ebook entity does not own stock. Running this example as-is raises an error for this reason. So, I offer up this workaround; it's a little ugly but it runs.

Whether this behaviour is intended or whether it is an issue with the type inference engine is beyond me!

----
__-> Commit__

Expand Down Expand Up @@ -210,10 +211,12 @@ put $book isa book, has isbn "0195153448";
----

A put is equivalent to doing:

[,typeql]
----
match not { <pattern> };
insert <pattern>;
----
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This missing delimiter is causing quite a considerable rendering problem on the site.


**It's highly recommended use `put` with a `key`-ed attributes**. This will prevent duplicates from emerging during concurrent transactions, as one will be forced to fail.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ In addition to being more efficient and easier for readers to interpret, these q
----
match
$book isa book, has $art;
$art "art" isa genre;
$art isa genre "art";
delete
has $art of $book;
insert
Expand All @@ -59,7 +59,7 @@ When updating an attribute ownership (or indeed, a role player in an existing re
----
match
$book isa paperback, has isbn-10 "0060929790";
update $book has stock 20;
update $book has stock 25;
----

The `update` clause will, for each statement written, set the new attribute to be the only attribute owned by the owner. In this example, for the specific paperback book, it sets the stock to 25, replacing any existing stock value.
Comment on lines +62 to 65
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dealer's choice whether to change the block or the descriptor, but they should match.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ insert
locating ($us, $ga);
----

In this case, the query was invalid because TypeDB cannot infer the roles that `$us` and `$ga` should play, but there are many reasons a query can be invalid. Try running each of the following ones to see what happens.
In this case, the query was invalid because TypeDB cannot infer the roles that `$us` and `$ga` should play, but there are many reasons a query can be invalid. Try running (and committing) each of the following ones to see what happens.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second query runs and only raises an error when you try to commit it.


[,typeql]
----
Expand Down
4 changes: 4 additions & 0 deletions academy/modules/ROOT/pages/4-writing-data/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ Learn about how new data is validated against the schema.

== Running examples

// TODO: Either remove the part about tagging or tag all the examples in this chapter.
To run an Insert, Delete, or Update query, make sure to use a *data* session and *write* transaction. The examples and exercises featured in this lesson are annotated with one of the following instructions to indicate how they should be run. Each write query should only be run once. Running write queries more than once may have unintended effects, such as inserting duplicate data.

// TODO: Fix the formatting of this block. Should it be paragraphs or a listing?
// TODO: Add the images referred to in this block.
:: *Run* this query without committing the transaction afterward. Write transactions will remain open for further queries, and changes will not be persisted until a commit.
image:{page-version}@home::studio-icons/svg/studio_run.svg[width=24]image:{page-version}@home::studio-icons/svg/studio_check.svg[width=24] *_Run and commit_*:: *Run* this query and then *commit* the transaction, persisting the changes to the database.
image:{page-version}@home::studio-icons/svg/studio_fail.svg[width=24] *_Do not run_*:: Do not run this query, which is shown for information only. To rollback an open transaction, *close* it without committing.
image:{page-version}@home::studio-icons/svg/studio_run.svg[width=24] *_Try running_*:: *Run* this query to see the error generated.

// TODO: Write this tutorial
For information on how to control sessions, transactions, and queries using TypeDB Studio, refer back to xref:{page-version}@academy::2-environment-setup/2.2-using-typedb-studio.adoc[Lesson 2.2].

== TypeQL keywords introduced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun transitive_places_new($place: place) -> { place }:
return { $parent };
----

This function is a recursive function, returning a stream of places (as indicated in the function signature with `{}` and in the return with `{}) based on a match query.
This function is a recursive function, returning a stream of places (as indicated in the function signature with `{}` and in the return with `{}`) based on a match query.

== Function return types

Expand Down
2 changes: 2 additions & 0 deletions academy/modules/ROOT/pages/5-defining-schemas/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ Learn about how types and functions are validated against the schema.

== Running examples

// TODO: Add the database manager icon file.
The sample database already has the complete bookstore schema defined and data inserted. If you would like to try running the Define queries featured in the examples and exercises in this section, then you should do so using another database. To create a new database, use the *database manager* image:{page-version}@home::studio-icons/svg/studio_dbs.svg[width=24]. After creation, make sure to switch over to it using the *database selector*. For more information on how to manage databases using TypeDB Studio, refer back to xref:{page-version}@academy::2-environment-setup/2.2-using-typedb-studio.adoc[Lesson 2.2]

To run a Define query, make sure to use a *schema* session and *write* transaction. After running a Define query, you should see any committed changes to the schema reflected in the *type browser*. The examples and exercises featured in this lesson are annotated with one of the following instructions to indicate how they should be run.

// TODO: Fix the formatting here to follow the index of Chapter 4.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:: *Run* this query without committing the transaction afterward. Write transactions will remain open for further queries, and changes will not be persisted until a commit.
_-> Commit_:: *Run* this query and then *commit* the transaction, persisting the changes to the database.
image:{page-version}@home::studio-icons/svg/studio_fail.svg[width=24] *_Do not run_*:: Do not run this query, which is shown for information only. To rollback an open transaction, *close* it without committing.
Expand Down