Skip to content

Commit f0cbba6

Browse files
Merge pull request #475 from colquhounking/edit-for-clarity
Edited for clarity and to remove gendered language
2 parents e5c6807 + 4f0a66c commit f0cbba6

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • samples/demos/sql-graph/recommendation-system

samples/demos/sql-graph/recommendation-system/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SQL Server 2017, thanks to Graph Database, can express certain kinds of queries
66

77
These demos, based on [WideWorldImporters](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/wide-world-importers) sample database, are related to the session that [Sergio Govoni](https://mvp.microsoft.com/it-it/PublicProfile/4029181?fullName=Sergio%20Govoni) has done at the PASS SQL Saturday 675 in Parma (Italy).
88

9-
For those who don't already know the [SQL Saturday](http://www.sqlsaturday.com) events: Since 2007, the PASS SQL Saturday program provides to users around the world the opportunity to organize free training sessions on SQL Server and related technologies. SQL Saturday is an event sponsored by PASS and therefore offers excellent opportunities for training, professional exchange and networking. You can find all details in this page: [About PASS SQL Saturday](http://www.sqlsaturday.com/about.aspx).
9+
For those who don't already know the [SQL Saturday](http://www.sqlsaturday.com) events: Since 2007, the PASS SQL Saturday program provides users around the world the opportunity to organize free training sessions on SQL Server and related technologies. SQL Saturday is an event sponsored by PASS and therefore offers excellent opportunities for training, professional exchange and networking. You can find all details in this page: [About PASS SQL Saturday](http://www.sqlsaturday.com/about.aspx).
1010

1111

1212
### Contents
@@ -80,21 +80,21 @@ The purpose of the file [before-you-begin.sql](./before-you-begin.sql) is to con
8080

8181
### Create and populate graph objects
8282

83-
The first demo consists in creating graph objects such as Nodes and Edges, this is the purpose of the file [demo1-create-and-populate-nodes-and-edges.sql](./demo1-create-and-populate-nodes-and-edges.sql). Let's start with the Node table named **Nodes.Person**. A node table represents an entity in a Graph DB, every time a node is created, in addition to the user defined columns, SQL Server Engine will create an implicit column named **$node_id** that uniquely identifies a given node in the database, it contains a combination of the **object_id** of the node and an internally bigint stored in an hidden column named **graph_id**.
83+
The first demo consists of creating graph objects such as Nodes and Edges, this is the purpose of the file [demo1-create-and-populate-nodes-and-edges.sql](./demo1-create-and-populate-nodes-and-edges.sql). Let's start with the Node table named **Nodes.Person**. A node table represents an entity in a Graph DB, every time a node is created, in addition to the user defined columns, SQL Server Engine will create an implicit column named **$node_id** that uniquely identifies a given node in the database, it contains a combination of the **object_id** of the node and an internally bigint stored in an hidden column named **graph_id**.
8484

85-
The following picture shows the CREATE statement with the new DDL extension **AS NODE**, this extension tells to the engine that we want to create a Node table.
85+
The following picture shows the CREATE statement with the new DDL extension **AS NODE**, this extension tells the engine that we want to create a Node table.
8686

8787
![Picture 1](../../../../media/demos/sql-graph/Create%20a%20Node%20Table.png)
8888

89-
Now, it's the time to create the Edge table named **Edges.Friends**. Every Edge represents a relationship in a graph, it may or may not have any user defined attributes, Edges are always directed and connected with two nodes. In the first release of SQL Graph, constraints are not available on the Edge table, so an Edge table can connect any two nodes on the graph. Every time an Edge table is created, in addition to the user defined columns, the Engine will create three implicit columns:
89+
Now, it's time to create the Edge table named **Edges.Friends**. Every Edge represents a relationship in a graph, it may or may not have any user defined attributes, Edges are always directed and connected with two nodes. In the first release of SQL Graph, constraints are not available on the Edge table, so an Edge table can connect any two nodes on the graph. Every time an Edge table is created, in addition to the user defined columns, the Engine will create three implicit columns:
9090

9191
1. **$edge_id** is a combination of the **object_id** of the Edge and an internally bigint stored in an hidden column named **graph_id**
9292

9393
2. **$from_id** stores the **$node_id** of the node where the Edge starts from
9494

9595
3. **$to_id** stores the **$node_id** of the node at which the Edge ends
9696

97-
The following picture shows the CREATE statement with the new DDL extension **AS EDGE**, this extension tells to the engine that we want to create an Edge table.
97+
The following picture shows the CREATE statement with the new DDL extension **AS EDGE**, this extension tells the engine that we want to create an Edge table.
9898

9999
![Picture 2](../../../../media/demos/sql-graph/Create%20an%20Edge%20Table.png)
100100

@@ -106,7 +106,7 @@ The second demo allows you to do a first look to the MATCH clause used to perfor
106106

107107
The new T-SQL MATCH function allows you to specify the search pattern for a graph schema, it can be used only with graph Node and Edge tables in SELECT statements as a part of the WHERE clause. Based on the node **Nodes.Person** and the edge **Edges.Friends**, the file [demo2-using-the-match-clause.sql](./demo2-using-the-match-clause.sql) contains the following sample queries:
108108

109-
1. List of all guys that speak finnish with friends (Pattern: Node > Relationship > Node)
109+
1. List of all people who speak Finnish with friends (Pattern: Node > Relationship > Node)
110110

111111
2. List of the top 5 people who have friends that speak Greek in the first and second connections
112112

@@ -117,17 +117,17 @@ The search pattern, provided in the MATCH function, goes through one node to ano
117117

118118
### Build a sample recommendation system using SQL Graph
119119

120-
Supposing to have a customer (of the table Sales.Customers) connected to our e-commerce, this customer is looking for the product (of the table Warehouse.StockItems) "USB food flash drive - pizza slice" or he/she has just bought that product. Our goal is finding the similar products to the one he/she is looking at, based on the behavior of other customers. In short words, we have to find products that are recommended for another one.
120+
Suppose we have a customer (from the table Sales.Customers) connected to our e-commerce, and this customer is looking for the product (of the table Warehouse.StockItems) "USB food flash drive - pizza slice" or they have just bought that product. Our goal is finding similar products to the one they are looking at, based on the behavior of other customers.
121121

122122
The following picture shows a possible scenario for our sales recommendation system.
123123

124124
![Picture 3](../../../../media/demos/sql-graph/Sales%20Recommendation%20Scenario.png)
125125

126126
This is the algorithm:
127127

128-
1. Identify the customer and the product he/she is purchasing
128+
1. Identify the customer and the product they are purchasing
129129

130-
2. Identify the other customers who have purchased the same item he/she is looking for
130+
2. Identify the other customers who have purchased the same they are looking for
131131

132132
3. Find the other products that customers, at step two, have purchased
133133

@@ -139,13 +139,13 @@ The following picture shows the graphical representation of the algorithm.
139139

140140
The file [demo3-create-and-populate-nodes-and-edges.sql](./demo3-create-and-populate-nodes-and-edges.sql) contains the statements to create and populate the nodes **Nodes.Customers**, **Nodes.StockItems** and the edge **Edges.Bought** starting from the tables of WideWorldImporters DB.
141141

142-
How can Graph Database helps us to implement this algorithm?
142+
How can Graph Database help us to implement this algorithm?
143143

144-
MATCH clause can express certain kinds of queries more easily than relational JOINs; let's start, we will use the counts to prioritize the recommendations that is the simplest possible algorithm for a recommendation service, in reality more complex filters are applied on top, for example text analysis of the product reviews to arrive at similarly measures.
144+
MATCH clause can express certain kinds of queries more easily than relational JOINs. If we use the counts to prioritize the recommendations that is the simplest possible algorithm for a recommendation service, in reality more complex filters are applied on top, for example text analysis of the product reviews to arrive at similar measures.
145145

146146
The file [demo3-recommendation-system-for-sales.sql](./demo3-recommendation-system-for-sales.sql) contains the query that is able to extract top 5 products that are recommended for "USB food flash drive - pizza slice" using the MATCH clause.
147147

148-
The last query of the file [demo3-recommendation-system-for-sales.sql](./demo3-recommendation-system-for-sales.sql) shows you the implementation of the algorithm in the relational database using JOINs.. so you will know how many lines of code you would have wrote prior to SQL Graph Database.
148+
The last query of the file [demo3-recommendation-system-for-sales.sql](./demo3-recommendation-system-for-sales.sql) shows the implementation of the algorithm in the relational database using JOINs.. so you know how many lines of code you would have written prior to SQL Graph Database.
149149

150150
<a name=disclaimers></a>
151151

0 commit comments

Comments
 (0)