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
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] offers graph database capabilities to model many-to-many relationships. The graph relationships are integrated into [!INCLUDE[tsql-md](../../includes/tsql-md.md)] and receive the benefits of using [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] as the foundational database management system.
[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] offers graph database capabilities to model many-to-many relationships. The graph relationships are integrated into [!INCLUDE [tsql-md](../../includes/tsql-md.md)] and receive the benefits of using [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] as the foundational database management system.
21
23
22
24
## What is a graph database?
23
25
24
-
A graph database is a collection of nodes (or vertices) and edges (or relationships). A node represents an entity (for example, a person or an organization) and an edge represents a relationship between the two nodes that it connects (for example, likes or friends). Both nodes and edges may have properties associated with them. Here are some features that make a graph database unique:
26
+
A [graph database](/fabric/graph/graph-database) is a collection of nodes (or vertices) and edges (or relationships). A node represents an entity (for example, a person or an organization) and an edge represents a relationship between the two nodes that it connects (for example, likes or friends). Both nodes and edges might have properties associated with them. Here are some features that make a graph database unique:
25
27
26
-
-Edges or relationships are first class entities in a Graph Database and can have attributes or properties associated with them.
27
-
-A single edge can flexibly connect multiple nodes in a Graph Database.
28
-
-You can express pattern matching and multi-hop navigation queries easily.
29
-
-You can express transitive closure and polymorphic queries easily.
28
+
- Edges or relationships are first class entities in a Graph Database and can have attributes or properties associated with them.
29
+
- A single edge can flexibly connect multiple nodes in a Graph Database.
30
+
- You can express pattern matching and multi-hop navigation queries easily.
31
+
- You can express transitive closure and polymorphic queries easily.
30
32
31
33
## When to use a graph database
32
34
33
-
A relational database can achieve anything a graph database can. However, a graph database makes it easier to express certain kinds of queries. Also, with specific optimizations, certain queries may perform better. Your decision to choose either a relational or graph database is based on following factors:
35
+
A relational database can achieve anything a graph database can. However, a graph database makes it easier to express certain kinds of queries. Also, with specific optimizations, certain queries might perform better. Your decision to choose either a relational or graph database is based on following factors:
36
+
37
+
- Your application has hierarchical data. The **HierarchyID** data type can be used to implement hierarchies, but it has some limitations. For example, it doesn't allow you to store multiple parents for a node.
34
38
35
-
- Your application has hierarchical data. The HierarchyID datatype can be used to implement hierarchies, but it has some limitations. For example, it doesn't allow you to store multiple parents for a node.
36
-
- Your application has complex many-to-many relationships; as application evolves, new relationships are added.
37
-
- You need to analyze interconnected data and relationships.
39
+
- Your application has complex many-to-many relationships; as application evolves, new relationships are added.
38
40
39
-
## Graph features introduced in [!INCLUDE[sssql17](../../includes/sssql17-md.md)]
41
+
- You need to analyze interconnected data and relationships.
40
42
41
-
The following features were introduced in SQL Server 2017.
43
+
## Graph features introduced in SQL Server 2017
44
+
45
+
The following features were introduced in [!INCLUDE [sssql17-md](../../includes/sssql17-md.md)].
42
46
43
47
### Create graph objects
44
48
45
-
[!INCLUDE[tsql-md](../../includes/tsql-md.md)] extensions allow users to create node or edge tables. Both nodes and edges can have properties associated to them. Since, nodes and edges are stored as tables, all the operations that are supported on relational tables are supported on node or edge table. Here's an example:
49
+
[!INCLUDE[tsql-md](../../includes/tsql-md.md)] extensions allow users to create node or edge tables. Both nodes and edges can have properties associated to them. Since, nodes and edges are stored as tables, all the operations that are supported on relational tables are supported on node or edge table. Here's an example:
46
50
47
51
```sql
48
-
CREATETABLEPerson (ID INTEGERPRIMARY KEY, Name VARCHAR(100), Age INT) AS NODE;
49
-
CREATETABLEfriends (StartDate date) AS EDGE;
50
-
```
52
+
CREATETABLEPerson
53
+
(
54
+
ID INTPRIMARY KEY,
55
+
Name VARCHAR (100),
56
+
Age INT
57
+
) AS NODE;
58
+
CREATETABLEfriends
59
+
(
60
+
StartDate DATE
61
+
) AS EDGE;
62
+
```
51
63
52
64
The following diagram shows how Nodes and Edges are stored as tables.
53
65
54
-
:::image type="content" source="media/sql-graph-overview/person-friends-tables.png" alt-text="Diagram showing the Nodes and Edges are stored as tables.":::
66
+
:::image type="content" source="media/sql-graph-overview/person-friends-tables.png" alt-text="Diagram showing the Nodes and Edges are stored as tables." lightbox="media/sql-graph-overview/person-friends-tables.png":::
55
67
56
68
### Query language extensions
57
69
58
-
New `MATCH` clause is introduced to support pattern matching and multi-hop navigation through the graph. The `MATCH` function uses ASCII-art style syntax for pattern matching. For example, to find friends of "John":
70
+
New `MATCH` clause is introduced to support pattern matching and multi-hop navigation through the graph. The `MATCH` function uses ASCII-art style syntax for pattern matching. For example, to find friends of "John":
59
71
60
72
```sql
61
73
-- Find friends of John
62
-
SELECTPerson2.Name
63
-
FROM Person Person1, Friends, Person Person2
74
+
SELECTPerson2.Name
75
+
FROM Person ASPerson1, Friends, PersonAS Person2
64
76
WHERE MATCH(Person1-(Friends)->Person2)
65
-
ANDPerson1.Name='John';
77
+
ANDPerson1.Name='John';
66
78
```
67
79
68
-
### Fully integrated in [!INCLUDE [ssde](../../includes/ssdenoversion-md.md)]
80
+
### Fully integrated in SQL Server Database Engine
69
81
70
-
Graph extensions are fully integrated in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] engine. Use the same storage engine, metadata, query processor, etc. to store and query graph data. Query across graph and relational data in a single query. Combining graph capabilities with other [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] technologies like columnstore indexes, HA, R services, etc. SQL graph also supports all the security and compliance features available with [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].
82
+
Graph extensions are fully integrated in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] engine. Use the same storage engine, metadata, query processor, etc. to store and query graph data. Query across graph and relational data in a single query. Combining graph capabilities with other [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] technologies like columnstore indexes, HA, R services, etc. SQL graph also supports all the security and compliance features available with [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].
71
83
72
84
### Tooling and ecosystem
73
85
74
-
Benefit from existing tools and ecosystem that [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] offers. Tools like backup and restore, import and export, BCP just work out of the box. Other tools or services like SSIS, SSRS, or Power BI work with graph tables, just the way they work with relational tables.
86
+
Benefit from existing tools and ecosystem that [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] offers. Tools like backup and restore, import and export, and **bcp**just work out of the box. Other tools or services like [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)][!INCLUDE [ssisnoversion-md](../../includes/ssisnoversion-md.md)], [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)][!INCLUDE [ssrsnoversion-md](../../includes/ssrsnoversion-md.md)], or Power BI work with graph tables, just the way they work with relational tables.
75
87
76
88
## Edge constraints
77
89
78
-
An edge constraint is defined on a graph edge table and is a pair of node table(s) that a given edge type can connect. Edge constraints help developers restrict the type of nodes that a given edge can connect.
90
+
An edge constraint is defined on a graph edge table and is a pair of node tables that a given edge type can connect. Edge constraints help developers restrict the type of nodes that a given edge can connect.
79
91
80
-
To learn more about how to create and use edge constraints, refer to [Edge Constraints](../../relational-databases/tables/graph-edge-constraints.md).
92
+
To learn more about how to create and use edge constraints, refer to [Edge constraints](../tables/graph-edge-constraints.md).
81
93
82
94
## Merge DML
83
95
84
-
The [MERGE](../../t-sql/statements/merge-transact-sql.md) statement performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in a target table based on differences between the target table and the source table. Using MATCH predicates in a MERGE statement is now supported on Azure SQL Database and SQL Server vNext. That is, it's now possible to merge your current graph data (node or edge tables) with new data using the MATCH predicates to specify graph relationships in a single statement, instead of separate INSERT/UPDATE/DELETE statements.
96
+
The [MERGE](../../t-sql/statements/merge-transact-sql.md) statement performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in a target table based on differences between the target table and the source table. Using `MATCH` predicates in a `MERGE` statement is now supported on Azure SQL Database and SQL Server vNext. That is, it's now possible to merge your current graph data (node or edge tables) with new data using the `MATCH` predicates to specify graph relationships in a single statement, instead of separate `INSERT`, `UPDATE`, and `DELETE` statements.
85
97
86
-
To learn more about how match can be used in merge DML, refer to [MERGE Statement](../../t-sql/statements/merge-transact-sql.md).
98
+
To learn more about how match can be used in merge DML, refer to [MERGE](../../t-sql/statements/merge-transact-sql.md).
87
99
88
100
## Shortest path
89
101
90
-
The [SHORTEST_PATH](./sql-graph-shortest-path.md) function finds shortest path between any two nodes in a graph or starting from a given node to all the other nodes in the graph. `SHORTEST PATH` can also be used to find a transitive closure or for arbitrary length traversals in the graph.
102
+
The [SHORTEST_PATH](sql-graph-shortest-path.md) function finds shortest path between any two nodes in a graph or starting from a given node to all the other nodes in the graph. `SHORTEST PATH` can also be used to find a transitive closure or for arbitrary length traversals in the graph.
91
103
92
104
## Fabric SQL database
93
105
94
-
In Fabric SQL database, SQL Graph is allowed, but Node and Edge tables will not mirror to Fabric OneLake.
106
+
In Fabric SQL database, SQL Graph is allowed, but Node and Edge tables don't mirror to Fabric OneLake.
95
107
96
108
## Related content
97
109
98
-
-Read the [SQL Graph Database - Architecture](./sql-graph-architecture.md)
99
-
-To get started with SQL Graph, see [SQL Graph Database - Sample](./sql-graph-sample.md)
0 commit comments