You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: new_home/modules/ROOT/pages/get_started/schema.adoc
+14-16Lines changed: 14 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,14 +130,12 @@ Finally, commit the transaction by typing:
130
130
commit
131
131
----
132
132
133
-
Alternatively, you could use the command `close` to discard your changes and close the transaction.
134
-
--
135
-
====
136
-
137
133
[NOTE]
138
-
====
134
+
=====
139
135
A quick *tip* if you are using Console for this course. Queries on this page can be turned into runnable *Console scripts* by clicking the "`hidden lines`" button (image:{page-version}@new_home::/svg/eye.svg[width=24]).
140
136
These scripts can then be *pasted* directly into the server-level interface of Console, and run end-to-end simply by pressing kbd[Enter].
137
+
=====
138
+
--
141
139
====
142
140
143
141
== Defining your schema
@@ -201,10 +199,10 @@ Finally, commit the transaction by typing `commit` and press kbd[Enter]. You hav
201
199
202
200
Let us dissect the second query in a bit more detail.
203
201
204
-
* In the first line of the query we introduce the relation type `friendship` with a `friend` *role* (in _programmer lingo_: think of a role as a *trait* that other types can implement). In the same line, we also declare that each friendship requires _exactly two friends_ when created (`card` is short for "`cardinality`", and is a first example of an *annotation*. Annotations make schema statements much more specific - but more on that in a moment).
205
-
* In the second line, we then define that users *can play* the role of friends in friendships (in _programmer lingo_: the type `user` *implements* the "`friend-role`" trait).
202
+
* In the first line of the query we introduce the relation type `friendship` with a `friend` *role* (in _programmer lingo_: think of a role as a *interface* that other types can implement). In the same line, we also declare that each friendship requires _exactly two friends_ when created (`card` is short for "`cardinality`", and is a first example of an *annotation*. Annotations make schema statements much more specific - but more on that in a moment).
203
+
* In the second line, we then define that users *can play* the role of friends in friendships (in _programmer lingo_: the type `user` *implements* the "`friend-role`" interface).
206
204
207
-
It's worth pointing out that roles are only one of two kinds of traits that types may implement, the other being *ownership*: for example, in our first query above we defined that the `user` type "`implements the username owner trait`". These traits make our life very easy as we'll see, especially when dealing with type hierarchies!
205
+
It's worth pointing out that roles are only one of two kinds of interfaces that types may implement, the other being *ownership*: for example, in our first query above we defined that the `user` type "`implements the username owner interface`". These interfaces make our life very easy as we'll see, especially when dealing with type hierarchies!
208
206
209
207
Let's write a few more definition queries to get a feel of database schemas in TypeDB.
210
208
@@ -224,7 +222,7 @@ For example:
224
222
include::./schema.adoc[tag=define3]
225
223
----
226
224
227
-
This defines a `start-date` attribute and then declares each friendship may own a `start_date` (i.e., the type `friendship` implements the "`start-date owner`" trait). The definition is followed by a `@card` annotation, which specifies that friendships own _between_ zero or one start dates. In fact, this is the default cardinality, so you don't actually need `@card` here at all.
225
+
This defines a `start-date` attribute and then declares each friendship may own a `start_date` (i.e., the type `friendship` implements the "`start-date owner`" interface). The definition is followed by a `@card` annotation, which specifies that friendships own _between_ zero or one start dates. In fact, this is the default cardinality, so you don't actually need `@card` here at all.
228
226
229
227
The next query illustrates usage of "`unbounded`" cardinality together with another useful annotation, `@key`. This specifies that the `username` of a `user` should uniquely identify a user, i.e., it is a _key attribute_.
230
228
@@ -233,7 +231,7 @@ The next query illustrates usage of "`unbounded`" cardinality together with anot
233
231
include::./schema.adoc[tag=define4]
234
232
----
235
233
236
-
Importantly, different types may own the same attributes; and, similarly, different types may play the same role of a relation type. This flexibility of connecting types is a central feature of data modeling with TypeDB. Run the next query to define an `organization` type which shares many of the traits of `user`:
234
+
Importantly, different types may own the same attributes; and, similarly, different types may play the same role of a relation type. This flexibility of connecting types is a central feature of data modeling with TypeDB. Run the next query to define an `organization` type which shares many of the interfaces of `user`:
This defines a `start-date` attribute and then declares each friendship may own a `start_date` (i.e., the type `friendship` implements the "`start-date owner`" trait). The definition is followed by a `@card` annotation, which specifies that friendships own _between_ zero or one start dates. In fact, this is the default cardinality, so you don't actually need `@card` here at all.
269
+
This defines a `start-date` attribute and then declares each friendship may own a `start_date` (i.e., the type `friendship` implements the "`start-date owner`" interface). The definition is followed by a `@card` annotation, which specifies that friendships own _between_ zero or one start dates. In fact, this is the default cardinality, so you don't actually need `@card` here at all.
272
270
273
271
The next query illustrates usage of "`unbounded`" cardinality together with another useful annotation, `@key`. This specifies that the `username` of a `user` should uniquely identify a user, i.e., it is a _key attribute_.
274
272
@@ -289,7 +287,7 @@ user owns username @key;
289
287
include::./schema.adoc[tag=define4]
290
288
----
291
289
292
-
Importantly, different types may own the same attributes; and, similarly, different types may play the same role of a relation type. This flexibility of connecting types is a central feature of data modeling with TypeDB. Run the next query to define an `organization` type which shares many of the traits of `user`:
290
+
Importantly, different types may own the same attributes; and, similarly, different types may play the same role of a relation type. This flexibility of connecting types is a central feature of data modeling with TypeDB. Run the next query to define an `organization` type which shares many of the interfaces of `user`:
293
291
294
292
////
295
293
[,typeql]
@@ -325,14 +323,14 @@ Let's define two types that specialize our earlier `organization` type: namely,
325
323
----
326
324
include::./schema.adoc[tag=define6]
327
325
----
328
-
Note that we haven't defined any traits for companies and universities; indeed, all traits of the supertype `organization` are automatically *inherited*! That doesn't stop from defining new traits for our subtypes, of course:
326
+
Note that we haven't defined any interfaces for companies and universities; indeed, all interfaces of the supertype `organization` are automatically *inherited*! That doesn't stop from defining new interfaces for our subtypes, of course:
329
327
330
328
[,typeql]
331
329
----
332
330
include::./schema.adoc[tag=define7]
333
331
----
334
332
335
-
Of course, you would be able to give the new subtypes additional traits that are not inherited from the supertype as well!
333
+
Of course, you would be able to give the new subtypes additional interfaces that are not inherited from the supertype as well!
336
334
337
335
--
338
336
@@ -355,7 +353,7 @@ entity university sub organization;
355
353
#!test[schema]
356
354
include::./schema.adoc[tag=define6]
357
355
----
358
-
Note that we haven't defined any traits for companies and universities; indeed, all traits of the supertype `organization` are automatically *inherited*! That doesn't stop from defining new traits for our subtypes, of course:
356
+
Note that we haven't defined any interfaces for companies and universities; indeed, all interfaces of the supertype `organization` are automatically *inherited*! That doesn't stop from defining new interfaces for our subtypes, of course:
359
357
////
360
358
[,typeql]
361
359
----
@@ -374,7 +372,7 @@ user plays enrolment:student;
374
372
include::./schema.adoc[tag=define7]
375
373
----
376
374
377
-
Of course, you would be able to give the new subtypes additional traits that are not inherited from the supertype as well!
375
+
Of course, you would be able to give the new subtypes additional interfaces that are not inherited from the supertype as well!
378
376
379
377
Don't forget to commit the transaction by typing `commit` and pressing kbd[Enter].
Copy file name to clipboardExpand all lines: new_reference/modules/ROOT/pages/typeql/data_model.adoc
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ This page gives a brief technical overview of TypeDB's type system and query mod
5
5
In short, TypeDB's data model is based on a *type system* built from two key ingredients:
6
6
7
7
* a _single-inheritance_ subtyping system, allowing a type to specialize to zero or more subtypes.
8
-
* a _trait-based_ reference system, allowing instances to refer to other instances.
8
+
* a _interface-based_ reference system, allowing instances to refer to other instances.
9
9
10
10
TypeDB's query model is tailored to this type system, directly expressing subtyping and references in its query statements, but also allowing users to chain together queries and data operations into powerful *multi-stage data pipelines* for all types of workloads.
11
11
@@ -32,7 +32,7 @@ Instances of entity types, simply called entities, can be created _indepdently_,
32
32
11. *Relation types*, specified using the keyword `relation`, and are required to have at least one *associated role type* specified with the keyword `relates`.
33
33
+
34
34
--
35
-
Instances of relation types may reference (or "link") zero or more data instances for each associated role type, called their *players* of that role (these data instance must have types with corresponding *player trait*).
35
+
Instances of relation types may reference (or "link") zero or more data instances for each associated role type, called their *players* of that role (these data instance must have types with corresponding *player interface*).
36
36
37
37
For example, a friendship relations may link two friends (implemented by, say, two user entities).
38
38
@@ -41,7 +41,7 @@ Relations without role players will be removed (no "`dangling relations`").
41
41
11. *Attribute types*, specified using the keyword `attribute`, and required to have an *associated value type* (either structured or primitive) specified with the keyword `value`.
42
42
+
43
43
--
44
-
Instances of attribute types carry an *associated value* of the associated value type. They may also reference other data instances, called their *owners* (these data instances must have direct types with the corresponding *owner trait*). Two attributes are considered equal if they have the same associate value and have the same (origin) type.
44
+
Instances of attribute types carry an *associated value* of the associated value type. They may also reference other data instances, called their *owners* (these data instances must have direct types with the corresponding *owner interface*). Two attributes are considered equal if they have the same associate value and have the same (origin) type.
45
45
46
46
Attributes without owners will be removed (no "`dangling attributes`", unless the attribute type is marked as independent).
47
47
--
@@ -65,15 +65,15 @@ Two instances of a value type are equal exactly when their literal values are eq
65
65
Coming soon.
66
66
====
67
67
68
-
=== Type traits and "`objects vs attributes`"
68
+
=== Type interfaces and "`objects vs attributes`"
69
69
70
-
Entity types can have traits, i.e. play roles or own attribute types. This allows us to create connections of entities with other data.
70
+
Entity types can have interfaces, i.e. play roles or own attribute types. This allows us to create connections of entities with other data.
71
71
72
-
Relation types can also have traits, i.e. play roles or own attribute types. This, for example, allows the creation of nested relations (i.e., relations playing roles in other relations).
72
+
Relation types can also have interfaces, i.e. play roles or own attribute types. This, for example, allows the creation of nested relations (i.e., relations playing roles in other relations).
73
73
74
-
Since entity and relation types together make up "`first-class`" types in TypeDB's type system (when it comes to type traits) they are, together, also referred to as *object types*, whose instances are data *objects*.
74
+
Since entity and relation types together make up "`first-class`" types in TypeDB's type system (when it comes to type interfaces) they are, together, also referred to as *object types*, whose instances are data *objects*.
75
75
76
-
Attributes cannot have traits; they are merely typed associations of values to objects.
76
+
Attributes cannot have interfaces; they are merely typed associations of values to objects.
77
77
78
78
=== Subtyping
79
79
@@ -88,7 +88,7 @@ Data instances (i.e., entities, relation, are attributes) are stored using datab
88
88
89
89
== Definitions
90
90
91
-
User-defined types, their traits, and their subtyping structure, are created and modified through xref:{page-version}@new_reference::typeql/index.adoc#statements[definition statements] in xref:{page-version}@new_reference::typeql/index.adoc#queries[schema queries].
91
+
User-defined types, their interfaces, and their subtyping structure, are created and modified through xref:{page-version}@new_reference::typeql/index.adoc#statements[definition statements] in xref:{page-version}@new_reference::typeql/index.adoc#queries[schema queries].
Copy file name to clipboardExpand all lines: new_reference/modules/ROOT/pages/typeql/index.adoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,14 +106,14 @@ The former query introduces types, while the latter will query for types. The ge
106
106
Definitions in schema queries concern:
107
107
108
108
* *type* definitions, introducing new types via the appropriate keyword (`entity`, `relation` + `relates`, `attribute` + `value`). Types are referred to by a unique type *labels*; multiple aliases of the latter can be introduced (coming soon).
109
-
* *trait* definitions, introducing player or owner traits (via `plays` and `owns` keywords). Player traits allow type instances to be referred to as players in roles of relations. Owner traits allow type instances to be referred to as
110
-
* *subtyping* definitions, declare types to be subtypes of other types (via the keyword `sub`). Traits of supertypes are inherited by subtypes.
109
+
* *interface* definitions, introducing player or owner interfaces (via `plays` and `owns` keywords). Player interfaces allow type instances to be referred to as players in roles of relations. Owner interfaces allow type instances to be referred to as
110
+
* *subtyping* definitions, declare types to be subtypes of other types (via the keyword `sub`). interfaces of supertypes are inherited by subtypes.
111
111
112
112
=== Pattern statements
113
113
114
114
In contrast, in patterns we support a wide variety of syntax, including for:
115
115
116
-
* *Retrieving types* based on label, traits, and inheritance.
116
+
* *Retrieving types* based on label, interfaces, and inheritance.
117
117
* *Retrieving data* in types, e.g. based on references between data instance such as attribute ownerships and relation linkages (via keywords such as `has`, `links`, and anonymous versions thereof)
Copy file name to clipboardExpand all lines: new_reference/modules/ROOT/pages/typeql/keywords.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -290,7 +290,7 @@ Denotes the return signature of a function. See xref:{page-version}@new_referenc
290
290
Used to remove ownership of attributes and players of roles in xref:{page-version}@new_reference::typeql/pipelines/delete.adoc[Delete stages] of data pipelines.
291
291
292
292
`from`::
293
-
Used to remove traits, role specialisation, and annotations in xref:{page-version}@new_reference::typeql/schema/undefine.adoc[Undefine queries].
293
+
Used to remove interfaces, role specialisation, and annotations in xref:{page-version}@new_reference::typeql/schema/undefine.adoc[Undefine queries].
294
294
295
295
`in`::
296
296
Used to access stream or list elements. See xref:{page-version}@new_reference::typeql/statements/let-in.adoc[] for more information.
0 commit comments