TypeDB Studio
TypeDB Studio is an IDE that facilitates the development process for TypeDB databases.
With Studio developers can efficiently manage databases, execute queries, and explore query results, all within a unified environment. It has a built-in TypeQL support, as well as Type Browser, Type Editor, and query results visualizer.
Setting up
To prepare TypeDB Studio for work, you need to complete the following steps:
-
Select a project directory to save your queries locally.
-
Connect to a TypeDB server.
-
Select a database to work with.
Select a project directory
TypeDB Studio stores queries you create as TypeQL files in a local project directory. To select a project directory, click either Open Project in the Project panel, or the Open Project Directory button in the top toolbar.
Connect to TypeDB
Select TypeDB edition below, and follow the instructions:
-
Cloud
-
Core
-
In the TypeDB Cloud dashboard, find the cluster you want to connect, and click Connect. Copy the displayed connection URI, replacing the password placeholder with your actual database password.
-
In Studio, click Connect to TypeDB. Paste the copied URI into the Connection URI field and click Connect.
Click Connect to TypeDB. Your connection URI is typedb-core://<host>:<port>
(e.g: typedb-core://localhost:1729
).
Select a database
TypeDB can work with one database at a time. To select a database to work with, use the dropdown menu on the right from the database icon in the top toolbar.
If there are no databases yet, see how to create a new one.
If the dropdown menu is greyed out and unresponsive, then check your connection to TypeDB.
Querying
To send a query from TypeDB Studio to TypeDB:
-
Prepare a query in a tab
-
Run a query from a tab
-
See the results of your query in all available output formats
For more information on switching session/transaction types and controls over queries and transactions, see the Transaction controls section.
Prepare a query
TypeDB has a Text editor that can edit most text files and has a built-in syntax highlighting for TypeQL.
It can also run TypeQL queries from .tql
and .typeql
files.
Each file can have one or more queries.
To create a new file, open a new tab in the Text editor panel.
The file will be created and saved with temporary name in a hidden folder ./typedb-studio
inside the selected project directory.
There is an autosave feature that persists all the changes made in a file to disk.
It can be disabled in settings.
By manually saving a temporary file you can rename
and move it from the hidden folder.
Run a query
Select a session type () and a transaction type () in the top Toolbar.
To run a query file, open it in a tab of the Text editor panel and click the Run Query button from the top Toolbar.
For a write
transaction type wait for a query to complete its execution
and select one of the transaction control actions:
Commit,
Close, etc.
If a write
transaction committed successfully — a blue pop-up with confirmation is displayed.
If any error occurs during a transaction, it is shown as a red pop-up.
For more information on different control elements for query execution, see the Transaction controls section below.
Query results
Under the Text editor panel there is the Results panel. The Results panel is collapsed by default if no query has been run yet.
This panel has two sets of tabs: Run and Output. Run tabs represent separate runs of a query file. You can pin a tab to preserve it. Otherwise, it will be rewritten with the next run.
Output tabs represent different output formats for the results: Log and Graph. Log tab contains textual output, similar to TypeDB Console, as well as input log, and error messages. Graph tab is available for Get queries only. It uses Studio’s Graph Visualizer to build a graphical representation of query results.
Transaction controls
To control query execution, we have the top Toolbar elements located to the right from the database selection drop-down menu.
# | Name | Icon / Visual | Action description |
---|---|---|---|
1 |
Session type switch |
Select a session type to use for queries. |
|
2 |
Transaction type switch |
Select a transaction type to use for queries |
|
3 |
snapshot button |
Enable snapshot feature that encapsulates a transaction in a snapshot of a database’s data until the transaction is committed or closed. Write transactions are always snapshoted. May be enabled or disabled for read transactions. |
|
4 |
infer button |
Enable inferring data by rules.
Only available for |
|
5 |
explain button |
Enable explanations mechanics. |
|
6 |
Transaction status indicator |
Transaction activity indicator. |
|
7 |
Close transaction button |
Close active transaction without committing the results. |
|
8 |
Rollback transaction button |
Revert the transaction results without closing it. |
|
9 |
Commit transaction button |
Commit the changes and close the transaction. |
|
10 |
Run Query button |
Run query or queries in the active tab of the Text editor panel. It will open a transaction (with the session type and transaction type specified in the Toolbar on the left) and execute the TypeQL code against the selected database. |
|
11 |
Stop Signal button |
Stop query execution after the next result. |
Inference
To run a query with inference, enable the infer button before executing a query.
If the button is unavailable, double-check TypeDB connection,
database selection,
and transaction type being set to read
.
As a result of running a query with inference, you can get additional results via inference. If there are any inferred instances of data returned from a Get query, they will be highlighted with green color in the Graph Visualizer. See an example on the image to the right.
Explanation
To run a query with explanation, turn the explain button on before executing a query. To be able to do that, the infer and snapshot buttons must be enabled.
If the explain button is inactive, double-check that Studio is connected to TypeDB, a database is selected with a drop-down list in the toolbar, and the infer and snapshot buttons are on.
To see an explanation, find an inferred result in Graph Visualizer (should be highlighted in green) on the Graph tab and double-click on the highlighted result. If there is an explanation for the inferred result, it spawns in visualization as new concepts. If there is no additional explanation available for the selected result, or all explanations have already been spawned, a pop-up notification appears.
Connection management
To connect, disconnect, or change connection settings, use the Connect to TypeDB button in the top right corner. While connected to TypeDB, the button changes its label to server’s address.
Databases management
Creating and deleting databases can be done via the Manage Database window. To open the Manage Database window, make sure TypeDB Studio is connected to TypeDB server and click on the database button in the top toolbar.
To create a new database:
-
Enter the name for the new database
-
Push Create.
To delete a database:
-
Select a database to delete from a list of databases and click the trashcan icon on its right.
-
Confirm deletion by typing in the name of the database to delete and then clicking the Delete button.
Type Browser
Type Browser panel gives you a full overview of the type hierarchy for the currently selected database.
In an empty database, there are only three root types shown in the panel.
In a database with a schema, all types displayed in the exact hierarchy they were created (subtypes inside their supertypes).
Double-clicking on any type opens the Type Editor window with information about the selected type.
Type Editor
Type Editor is a powerful instrument that combines easy to use GUI with API calls that can modify schema types directly, without TypeQL queries. With Type Editor, it’s much easier to rename a type or change type hierarchy by changing a supertype of a type. And it works even for types that already have data inserted for them.
Type Editor window gives you a full overview of the selected type: its label, parent, owned attributes, played roles, owners (for attributes), related roles (for relations), subtypes, and whether it’s an abstract type.
Type Editor can rename a type, change its supertype, change whether it’s an abstract type, add or remove owned attributes, related roles, played roles, as well as just delete a type or export its full definition.
For the Type Editor be able to modify a schema,
make sure to switch to the schema
session and write
transaction in the top toolbar.
Rename a type
To rename a type:
-
Open the Type Editor window by double-clicking on the selected type in the Type Browser.
-
At the very top, click on the pencil icon immediately right from the type name.
-
Edit the name in the Label field and press the Rename button to save the changes.
-
Commit the transaction by the Commit button at the top toolbar.
You can also do the same by right-clicking on the type in the Type Browser panel and choosing the Rename Type option.
Renaming a type in any of these two ways updates the relevant type references in the schema and does not lead to loosing existing data. All existing instances of the type will be available under the new label.
Delete a type
To delete a type:
-
Open the Type Editor window by double-clicking on the selected type in the Type Browser.
-
At the very bottom, click the Delete button and then the Confirm button.
-
Commit the transaction by the Commit button at the top toolbar.
You can also do the same by right-clicking on the type in the Type browser panel and choosing the Delete option, then clicking the Confirm button.
In some cases, the Delete option and button can be unavailable. That means there are some conditions that prevent you from deleting this type. For example, we can’t delete a type that has a subtype.
Settings
To see TypeDB Studio settings, open the Manage Preferences window by clicking on the button with the gear (⚙) icon in the top right corner of the window.
Version Compatibility
For older TypeDB versions, you’ll need a compatible version of TypeDB Studio. Select the correct TypeDB Studio version from the version compatibility table, and download it from Cloudsmith.