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
{{ message }}
Repository navigation
Commit b42ae87
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: pages/memgraph-zero/memgql/schema-file.mdx
+50-14Lines changed: 50 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,8 +245,39 @@ A vertex maps a **label** to a backend source. Exactly one source kind is set:
245
245
}
246
246
```
247
247
248
+
A table whose rows should carry **more than one label** lists them under
249
+
`labels` instead of `label`. The first label identifies the mapping and must be
250
+
unique in the graph; the others may be shared with other mappings:
251
+
252
+
```json
253
+
{
254
+
"labels": ["Cat", "Animal"],
255
+
"mappedTableSource": {
256
+
"connector": "pg",
257
+
"table": "cats",
258
+
"metaFields": { "id": "cat_id" }
259
+
},
260
+
"attributes": [
261
+
{ "name": "id", "column": "cat_id" },
262
+
{ "name": "name" }
263
+
]
264
+
}
265
+
```
266
+
267
+
With a second mapping `["Dog", "Animal"]` over a `dogs` table keyed by
268
+
`dog_id`, `MATCH (a:Cat)` reads one table, `MATCH (a:Dog:Animal)` the other,
269
+
and `MATCH (a:Animal)` both — as one `UNION` statement inside the connector.
270
+
Shared property names resolve through each table's own columns, a property
271
+
only one table declares is `null` on the other's rows, and returned nodes
272
+
carry all of their labels (`(:Cat:Animal)`). Attributes that two carriers of a shared
273
+
label both declare must have the same `type`. A traversal or an `INSERT` has to
274
+
start from one table, so on a shared label both are refused with a pointer to
275
+
the identifying label. A label no mapping carries together with the others
276
+
matches nothing.
277
+
248
278
| Field | Source kind | Description |
249
279
|-------|-------------|-------------|
280
+
|`label` / `labels`| both | The node label, or a list of labels whose first entry identifies the mapping (unique per graph) and whose others may be shared with other mappings. |
250
281
|`mappedTableSource.connector`| relational | Connector name (alias `catalog`). |
|`mappedTableSource.database`| relational | Optional outer namespace for backends with three-part names; on SQL Server it renders `database.schema.table`, so one connection can reach views in other databases. |
@@ -318,9 +349,11 @@ labels; the traversal is resolved by the backend.
318
349
319
350
#### Cross-connector edges
320
351
321
-
A third source kind, `mappedJoinSource`, declares an edge whose two endpoints
322
-
live in **different connectors**. It has no backing table anywhere: the
323
-
relationship *is* equality between one property on each endpoint.
352
+
A third source kind, `mappedJoinSource`, declares an edge with **no backing
353
+
table anywhere**: the relationship *is* equality between one property on each
354
+
endpoint. It is how a traversal crosses into a **different connector**, and
355
+
also how two tables in the **same** connector are linked by a business key
356
+
rather than by a foreign key into the target's `metaFields.id`.
324
357
325
358
```json
326
359
{
@@ -361,19 +394,22 @@ don't collide.
361
394
**Rules and limits** (each is refused with a message saying what to write
362
395
instead):
363
396
364
-
- Both endpoints must live in different connectors — within one connector use
365
-
`mappedTableSource` with `metaFields.from` / `to`.
366
-
- Each key must be a declared `attribute` of its endpoint vertex (native-graph
367
-
vertices are exempt, since the query passes through).
368
-
- The edge must be traversed **in a direction**: `-[:R]->` or `<-[:R]-`, not
369
-
`-[:R]-`.
370
-
- No variable-length traversal, no `OPTIONAL MATCH`, and one `MATCH` with one
371
-
path pattern per query.
397
+
- Each key must be a declared `attribute` of its endpoint vertex, backed by a
398
+
plain scalar column (native-graph vertices are exempt, since the query passes
399
+
through). The edge declares no `attributes`.
372
400
- The edge carries no properties, so it cannot be filtered — filter the
373
401
endpoints instead.
374
-
- Every node in the pattern needs a label, so each side can be routed.
375
-
- Aggregating *across* the join (for example `count()` over both sides) is not
376
-
supported yet; return the rows and count client-side.
402
+
- Across connectors: the edge must be traversed **in a direction** (`-[:R]->`
403
+
or `<-[:R]-`, not `-[:R]-`); no variable-length traversal, no
404
+
`OPTIONAL MATCH`, one `MATCH` with one path pattern per query; every node in
405
+
the pattern needs a label, so each side can be routed; aggregating *across*
406
+
the join (`count()` over both sides) is not supported yet.
407
+
- Within one relational connector the edge is pushed down as a single `JOIN`
408
+
on the two key columns, so those limits do not apply: aggregates work, and an
409
+
undirected step is accepted when the two endpoint labels differ. A
410
+
variable-length step over it is refused. Both endpoints on a Memgraph or
411
+
Neo4j connector are refused — that backend stores its own relationships, so
412
+
declare `mappedGraphSource`.
377
413
378
414
A **table-backed** edge whose endpoints sit in different connectors is still
379
415
skipped at load time with a warning pointing at `mappedJoinSource`.
0 commit comments