@@ -21,11 +21,19 @@ client = WOQLClient(server_url)
21
21
client.connect(user = user,account = account,key = key,db = dbid)
22
22
```
23
23
24
+ If you haven't already created the database, you can do so with the
25
+ following query:
26
+
27
+ ``` python
28
+ client.create_database(dbid, label = label, description = description)
29
+ ```
30
+
24
31
Once we have a client object, we can proceed with adding a schema to
25
32
the database.
26
33
27
34
``` python
28
- address = WQ().doctype(" Address" )
35
+ address = WQ().woql_and(
36
+ WQ().doctype(" Address" )
29
37
.label(" An address record" )
30
38
.description(" Record holding address information" )
31
39
.property(" street" , " xsd:string" )
@@ -36,21 +44,31 @@ address = WQ().doctype("Address")
36
44
.cardinality(1 )
37
45
.property(" post_code" , " xsd:string" )
38
46
.label(" post code" )
39
- .max_cardinality (1 )
47
+ .max (1 )
40
48
41
- client.query(person).execute(client , " Adding Address documents to the database" )
49
+ client.query(address , " Adding Address documents to the database" )
42
50
```
43
51
44
52
We now have a schema description of what constitutes an address,
45
53
replete with documentation of the elements, and information about the
46
54
cardinalities of edges in the database.
47
55
48
- We can now use this document type to connect it to other elements in
56
+ The `label` groups with the current schema object we are creating and
57
+ gives it a human readable name. We can also use `description` to give
58
+ a lengthier destription to any of the created schema objects.
59
+
60
+ When we use `property ` we group it with the current class . This
61
+ current class is its domain. It comes together with its range as the
62
+ second argument after the name. If we have more complex properties
63
+ with overlapping ranges it is necessary to create them seperately.
64
+
65
+ We can use this document type to connect it to other elements in
49
66
the graph. For instance, we can create a new person document type as
50
67
follows:
51
68
52
69
```python
53
- person = WQ().doctype(" Person" )
70
+ person = WQ().woql_and(
71
+ WQ().doctype(" Person" )
54
72
.label(" A digital human twin" )
55
73
.description(" Record holding information on an individual" )
56
74
.property(" forename" , " xsd:string" )
@@ -60,7 +78,7 @@ person = WQ().doctype("Person")
60
78
.label(" surname" )
61
79
.cardinality(1 )
62
80
.property(" address" , " Address" )
63
- .label(" The address(es) associated with an individual" )
81
+ .label(" The address(es) associated with an individual" ))
64
82
65
83
client.query(person, " Adding Person record" )
66
84
```
0 commit comments