Skip to content

Instantly share code, notes, and snippets.

@DaveJPoole
Forked from jexp/meta_graph.adoc
Last active August 29, 2015 14:02
Show Gist options
  • Save DaveJPoole/a833d725392c5e710211 to your computer and use it in GitHub Desktop.
Save DaveJPoole/a833d725392c5e710211 to your computer and use it in GitHub Desktop.
Exploring a Relational DB schema using a Graph DB!

A demonstration using the Adventureworks sample DB

One of the challenges facing users of a data warehouse is to understand how the different tables within the warehouse relate to each other.

A graph database can solve this problem easily if we copy the table and foreign key metadata into a Cypher script.

I wrote up the full experiment but include the data here as an example.

Adventureworks structure in Cypher

MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r;
CREATE (n2099048:Productiontable{name:"ProductModelProductDescriptionCulture",schema:"Production",description:"Cross-reference table mapping product descriptions and the language the description is written in."})
CREATE (n5575058:dbotable{name:"ErrorLog",schema:"dbo",description:"Audit table tracking errors in the the AdventureWorks database that are caught by the CATCH block of a TRY...CATCH construct. Data is inserted by stored procedure dbo.uspLogError when it is executed from inside the CATCH block of a TRY...CATCH construct."})
CREATE (n30623152:Salestable{name:"Store",schema:"Sales",description:"Customers (resellers) of Adventure Works products."})
CREATE (n34099162:Productiontable{name:"ProductPhoto",schema:"Production",description:"Product images."})
CREATE (n66099276:Productiontable{name:"ProductProductPhoto",schema:"Production",description:"Cross-reference table mapping products and product photos."})
CREATE (n78623323:Salestable{name:"StoreContact",schema:"Sales",description:"Cross-reference table mapping stores and their employees."})
CREATE (n101575400:Persontable{name:"Address",schema:"Person",description:"Street address information for customers, employees, and vendors."})
CREATE (n114099447:Productiontable{name:"ProductReview",schema:"Production",description:"Customer reviews of products they have purchased."})
CREATE (n126623494:Productiontable{name:"TransactionHistory",schema:"Production",description:"Record of each purchase order, sales order, or work order transaction year to date."})
CREATE (n149575571:Persontable{name:"AddressType",schema:"Person",description:"Types of addresses stored in the Address table. "})
CREATE (n178099675:Productiontable{name:"ProductSubcategory",schema:"Production",description:"Product subcategories. See ProductCategory table."})
CREATE (n197575742:dbotable{name:"AWBuildVersion",schema:"dbo",description:"Current version number of the AdventureWorks sample database. "})
CREATE (n206623779:Productiontable{name:"TransactionHistoryArchive",schema:"Production",description:"Transactions for previous years."})
CREATE (n226099846:Purchasingtable{name:"ProductVendor",schema:"Purchasing",description:"Cross-reference table mapping vendors with the products they supply."})
CREATE (n229575856:Productiontable{name:"BillOfMaterials",schema:"Production",description:"Items required to make bicycles and bicycle subassemblies. It identifies the heirarchical relationship between a parent product and its components."})
CREATE (n286624064:Productiontable{name:"UnitMeasure",schema:"Production",description:"Unit of measure lookup table."})
CREATE (n318624178:Purchasingtable{name:"Vendor",schema:"Purchasing",description:"Companies from whom Adventure Works Cycles purchases parts or other goods."})
CREATE (n354100302:Purchasingtable{name:"PurchaseOrderDetail",schema:"Purchasing",description:"Individual products associated with a specific purchase order. See PurchaseOrderHeader."})
CREATE (n357576312:Persontable{name:"Contact",schema:"Person",description:"Names of each employee, customer contact, and vendor contact."})
CREATE (n398624463:Purchasingtable{name:"VendorAddress",schema:"Purchasing",description:"Cross-reference mapping vendors and addresses."})
CREATE (n430624577:Purchasingtable{name:"VendorContact",schema:"Purchasing",description:"Cross-reference table mapping vendors and their employees."})
CREATE (n450100644:Purchasingtable{name:"PurchaseOrderHeader",schema:"Purchasing",description:"General purchase order information. See PurchaseOrderDetail."})
CREATE (n453576654:Salestable{name:"ContactCreditCard",schema:"Sales",description:"Cross-reference table mapping customers in the Contact table to their credit card information in the CreditCard table. "})
CREATE (n462624691:Productiontable{name:"WorkOrder",schema:"Production",description:"Manufacturing work orders."})
CREATE (n485576768:Persontable{name:"ContactType",schema:"Person",description:"Lookup table containing the types of contacts stored in Contact."})
CREATE (n517576882:Salestable{name:"CountryRegionCurrency",schema:"Sales",description:"Cross-reference table mapping ISO currency codes to a country or region."})
CREATE (n542624976:Productiontable{name:"WorkOrderRouting",schema:"Production",description:"Work order details."})
CREATE (n549576996:Persontable{name:"CountryRegion",schema:"Person",description:"Lookup table containing the ISO standard codes for countries and regions."})
CREATE (n581577110:Salestable{name:"CreditCard",schema:"Sales",description:"Customer credit card information."})
CREATE (n613577224:Productiontable{name:"Culture",schema:"Production",description:"Lookup table containing the languages in which some AdventureWorks data is stored."})
CREATE (n645577338:Salestable{name:"Currency",schema:"Sales",description:"Lookup table containing standard ISO currencies."})
CREATE (n658101385:Salestable{name:"SalesOrderDetail",schema:"Sales",description:"Individual products associated with a specific sales order. See SalesOrderHeader."})
CREATE (n677577452:Salestable{name:"CurrencyRate",schema:"Sales",description:"Currency exchange rates."})
CREATE (n709577566:Salestable{name:"Customer",schema:"Sales",description:"Current customer information. Also see the Individual and Store tables."})
CREATE (n770101784:Salestable{name:"SalesOrderHeader",schema:"Sales",description:"General sales order information."})
CREATE (n773577794:Salestable{name:"CustomerAddress",schema:"Sales",description:"Cross-reference table mapping customers to their address(es)."})
CREATE (n821577965:HumanResourcestable{name:"Department",schema:"HumanResources",description:"Lookup table containing the departments within the Adventure Works Cycles company."})
CREATE (n853578079:Productiontable{name:"Document",schema:"Production",description:"Product maintenance documents."})
CREATE (n917578307:HumanResourcestable{name:"Employee",schema:"HumanResources",description:"Employee information such as salary, department, and title."})
CREATE (n1026102696:Salestable{name:"SalesOrderHeaderSalesReason",schema:"Sales",description:"Cross-reference table mapping sales orders to sales reason codes."})
CREATE (n1058102810:Salestable{name:"SalesPerson",schema:"Sales",description:"Sales representative current information."})
CREATE (n1125579048:HumanResourcestable{name:"EmployeeAddress",schema:"HumanResources",description:"Cross-reference table mapping employees to their address(es)."})
CREATE (n1173579219:HumanResourcestable{name:"EmployeeDepartmentHistory",schema:"HumanResources",description:"Employee department transfers."})
CREATE (n1221579390:HumanResourcestable{name:"EmployeePayHistory",schema:"HumanResources",description:"Employee pay history."})
CREATE (n1250103494:Salestable{name:"SalesPersonQuotaHistory",schema:"Sales",description:"Sales performance tracking."})
CREATE (n1285579618:Productiontable{name:"Illustration",schema:"Production",description:"Bicycle assembly diagrams."})
CREATE (n1314103722:Salestable{name:"SalesReason",schema:"Sales",description:"Lookup table of customer purchase reasons."})
CREATE (n1317579732:Salestable{name:"Individual",schema:"Sales",description:"Demographic data about customers that purchase Adventure Works products online."})
CREATE (n1346103836:Salestable{name:"SalesTaxRate",schema:"Sales",description:"Tax rate lookup table."})
CREATE (n1349579846:HumanResourcestable{name:"JobCandidate",schema:"HumanResources",description:"Résumés submitted to Human Resources by job applicants."})
CREATE (n1381579960:Productiontable{name:"Location",schema:"Production",description:"Product inventory and manufacturing locations."})
CREATE (n1426104121:Salestable{name:"SalesTerritory",schema:"Sales",description:"Sales territory lookup table."})
CREATE (n1477580302:Productiontable{name:"Product",schema:"Production",description:"Products sold or used in the manfacturing of sold products."})
CREATE (n1602104748:Salestable{name:"SalesTerritoryHistory",schema:"Sales",description:"Sales representative transfers to other sales territories."})
CREATE (n1666104976:Productiontable{name:"ScrapReason",schema:"Production",description:"Manufacturing failure reasons lookup table."})
CREATE (n1698105090:HumanResourcestable{name:"Shift",schema:"HumanResources",description:"Work shift lookup table."})
CREATE (n1717581157:Productiontable{name:"ProductCategory",schema:"Production",description:"High-level product categorization."})
CREATE (n1730105204:Purchasingtable{name:"ShipMethod",schema:"Purchasing",description:"Shipping company lookup table."})
CREATE (n1765581328:Productiontable{name:"ProductCostHistory",schema:"Production",description:"Changes in the cost of a product over time."})
CREATE (n1829581556:Productiontable{name:"ProductDescription",schema:"Production",description:"Product descriptions in several languages."})
CREATE (n1842105603:Salestable{name:"ShoppingCartItem",schema:"Sales",description:"Contains online customer orders until the order is submitted or cancelled."})
CREATE (n1877581727:Productiontable{name:"ProductDocument",schema:"Production",description:"Cross-reference table mapping products to related product documents."})
CREATE (n1909581841:Productiontable{name:"ProductInventory",schema:"Production",description:"Product inventory information."})
CREATE (n1922105888:Salestable{name:"SpecialOffer",schema:"Sales",description:"Sale discounts lookup table."})
CREATE (n2005582183:Productiontable{name:"ProductListPriceHistory",schema:"Production",description:"Changes in the list price of a product over time."})
CREATE (n2066106401:Salestable{name:"SpecialOfferProduct",schema:"Sales",description:"Cross-reference table mapping products to special offer discounts."})
CREATE (n2069582411:Productiontable{name:"ProductModel",schema:"Production",description:"Product model classification."})
CREATE (n2114106572:Persontable{name:"StateProvince",schema:"Person",description:"State and province lookup table."})
CREATE (n2117582582:Productiontable{name:"ProductModelIllustration",schema:"Production",description:"Cross-reference table mapping product models and illustrations."})
CREATE (n2121058592:dbotable{name:"DatabaseLog",schema:"dbo",description:"Audit table tracking all DDL changes made to the AdventureWorks database. Data is captured by the database trigger ddlDatabaseTriggerLog."})
CREATE (n2011154210:dbotable{name:"test_table",schema:"dbo",description:""})
CREATE (n11147085:FK{name:"FK_EmployeeDepartmentHistory_Shift_ShiftID",parentObject:"[HumanResources].[EmployeeDepartmentHistory]",referencedObject:"[HumanResources].[Shift]",joinCondition:"P.ShiftID=R.ShiftID"})
CREATE (n27147142:FK{name:"FK_EmployeePayHistory_Employee_EmployeeID",parentObject:"[HumanResources].[EmployeePayHistory]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.EmployeeID=R.EmployeeID"})
CREATE (n43147199:FK{name:"FK_Individual_Customer_CustomerID",parentObject:"[Sales].[Individual]",referencedObject:"[Sales].[Customer]",joinCondition:"P.CustomerID=R.CustomerID"})
CREATE (n59147256:FK{name:"FK_Individual_Contact_ContactID",parentObject:"[Sales].[Individual]",referencedObject:"[Person].[Contact]",joinCondition:"P.ContactID=R.ContactID"})
CREATE (n75147313:FK{name:"FK_JobCandidate_Employee_EmployeeID",parentObject:"[HumanResources].[JobCandidate]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.EmployeeID=R.EmployeeID"})
CREATE (n91147370:FK{name:"FK_Product_UnitMeasure_SizeUnitMeasureCode",parentObject:"[Production].[Product]",referencedObject:"[Production].[UnitMeasure]",joinCondition:"P.SizeUnitMeasureCode=R.UnitMeasureCode"})
CREATE (n107147427:FK{name:"FK_Product_UnitMeasure_WeightUnitMeasureCode",parentObject:"[Production].[Product]",referencedObject:"[Production].[UnitMeasure]",joinCondition:"P.WeightUnitMeasureCode=R.UnitMeasureCode"})
CREATE (n123147484:FK{name:"FK_Product_ProductModel_ProductModelID",parentObject:"[Production].[Product]",referencedObject:"[Production].[ProductModel]",joinCondition:"P.ProductModelID=R.ProductModelID"})
CREATE (n139147541:FK{name:"FK_Product_ProductSubcategory_ProductSubcategoryID",parentObject:"[Production].[Product]",referencedObject:"[Production].[ProductSubcategory]",joinCondition:"P.ProductSubcategoryID=R.ProductSubcategoryID"})
CREATE (n155147598:FK{name:"FK_ProductCostHistory_Product_ProductID",parentObject:"[Production].[ProductCostHistory]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n171147655:FK{name:"FK_ProductDocument_Product_ProductID",parentObject:"[Production].[ProductDocument]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n187147712:FK{name:"FK_ProductDocument_Document_DocumentID",parentObject:"[Production].[ProductDocument]",referencedObject:"[Production].[Document]",joinCondition:"P.DocumentID=R.DocumentID"})
CREATE (n203147769:FK{name:"FK_ProductInventory_Location_LocationID",parentObject:"[Production].[ProductInventory]",referencedObject:"[Production].[Location]",joinCondition:"P.LocationID=R.LocationID"})
CREATE (n219147826:FK{name:"FK_ProductInventory_Product_ProductID",parentObject:"[Production].[ProductInventory]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n235147883:FK{name:"FK_ProductListPriceHistory_Product_ProductID",parentObject:"[Production].[ProductListPriceHistory]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n251147940:FK{name:"FK_ProductModelIllustration_ProductModel_ProductModelID",parentObject:"[Production].[ProductModelIllustration]",referencedObject:"[Production].[ProductModel]",joinCondition:"P.ProductModelID=R.ProductModelID"})
CREATE (n267147997:FK{name:"FK_ProductModelIllustration_Illustration_IllustrationID",parentObject:"[Production].[ProductModelIllustration]",referencedObject:"[Production].[Illustration]",joinCondition:"P.IllustrationID=R.IllustrationID"})
CREATE (n283148054:FK{name:"FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID",parentObject:"[Production].[ProductModelProductDescriptionCulture]",referencedObject:"[Production].[ProductDescription]",joinCondition:"P.ProductDescriptionID=R.ProductDescriptionID"})
CREATE (n299148111:FK{name:"FK_ProductModelProductDescriptionCulture_Culture_CultureID",parentObject:"[Production].[ProductModelProductDescriptionCulture]",referencedObject:"[Production].[Culture]",joinCondition:"P.CultureID=R.CultureID"})
CREATE (n315148168:FK{name:"FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID",parentObject:"[Production].[ProductModelProductDescriptionCulture]",referencedObject:"[Production].[ProductModel]",joinCondition:"P.ProductModelID=R.ProductModelID"})
CREATE (n331148225:FK{name:"FK_ProductProductPhoto_Product_ProductID",parentObject:"[Production].[ProductProductPhoto]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n347148282:FK{name:"FK_ProductProductPhoto_ProductPhoto_ProductPhotoID",parentObject:"[Production].[ProductProductPhoto]",referencedObject:"[Production].[ProductPhoto]",joinCondition:"P.ProductPhotoID=R.ProductPhotoID"})
CREATE (n363148339:FK{name:"FK_ProductReview_Product_ProductID",parentObject:"[Production].[ProductReview]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n379148396:FK{name:"FK_ProductSubcategory_ProductCategory_ProductCategoryID",parentObject:"[Production].[ProductSubcategory]",referencedObject:"[Production].[ProductCategory]",joinCondition:"P.ProductCategoryID=R.ProductCategoryID"})
CREATE (n395148453:FK{name:"FK_ProductVendor_Product_ProductID",parentObject:"[Purchasing].[ProductVendor]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n411148510:FK{name:"FK_ProductVendor_UnitMeasure_UnitMeasureCode",parentObject:"[Purchasing].[ProductVendor]",referencedObject:"[Production].[UnitMeasure]",joinCondition:"P.UnitMeasureCode=R.UnitMeasureCode"})
CREATE (n427148567:FK{name:"FK_ProductVendor_Vendor_VendorID",parentObject:"[Purchasing].[ProductVendor]",referencedObject:"[Purchasing].[Vendor]",joinCondition:"P.VendorID=R.VendorID"})
CREATE (n443148624:FK{name:"FK_PurchaseOrderDetail_Product_ProductID",parentObject:"[Purchasing].[PurchaseOrderDetail]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n459148681:FK{name:"FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID",parentObject:"[Purchasing].[PurchaseOrderDetail]",referencedObject:"[Purchasing].[PurchaseOrderHeader]",joinCondition:"P.PurchaseOrderID=R.PurchaseOrderID"})
CREATE (n475148738:FK{name:"FK_PurchaseOrderHeader_Employee_EmployeeID",parentObject:"[Purchasing].[PurchaseOrderHeader]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.EmployeeID=R.EmployeeID"})
CREATE (n491148795:FK{name:"FK_PurchaseOrderHeader_Vendor_VendorID",parentObject:"[Purchasing].[PurchaseOrderHeader]",referencedObject:"[Purchasing].[Vendor]",joinCondition:"P.VendorID=R.VendorID"})
CREATE (n507148852:FK{name:"FK_PurchaseOrderHeader_ShipMethod_ShipMethodID",parentObject:"[Purchasing].[PurchaseOrderHeader]",referencedObject:"[Purchasing].[ShipMethod]",joinCondition:"P.ShipMethodID=R.ShipMethodID"})
CREATE (n523148909:FK{name:"FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID",parentObject:"[Sales].[SalesOrderDetail]",referencedObject:"[Sales].[SalesOrderHeader]",joinCondition:"P.SalesOrderID=R.SalesOrderID"})
CREATE (n539148966:FK{name:"FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID",parentObject:"[Sales].[SalesOrderDetail]",referencedObject:"[Sales].[SpecialOfferProduct]",joinCondition:"P.SpecialOfferID=R.SpecialOfferID AND P.ProductID=R.ProductID"})
CREATE (n555149023:FK{name:"FK_SalesOrderHeader_Address_BillToAddressID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Person].[Address]",joinCondition:"P.BillToAddressID=R.AddressID"})
CREATE (n571149080:FK{name:"FK_SalesOrderHeader_Address_ShipToAddressID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Person].[Address]",joinCondition:"P.ShipToAddressID=R.AddressID"})
CREATE (n587149137:FK{name:"FK_SalesOrderHeader_Contact_ContactID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Person].[Contact]",joinCondition:"P.ContactID=R.ContactID"})
CREATE (n603149194:FK{name:"FK_SalesOrderHeader_CreditCard_CreditCardID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Sales].[CreditCard]",joinCondition:"P.CreditCardID=R.CreditCardID"})
CREATE (n619149251:FK{name:"FK_SalesOrderHeader_CurrencyRate_CurrencyRateID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Sales].[CurrencyRate]",joinCondition:"P.CurrencyRateID=R.CurrencyRateID"})
CREATE (n635149308:FK{name:"FK_SalesOrderHeader_Customer_CustomerID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Sales].[Customer]",joinCondition:"P.CustomerID=R.CustomerID"})
CREATE (n651149365:FK{name:"FK_SalesOrderHeader_SalesPerson_SalesPersonID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Sales].[SalesPerson]",joinCondition:"P.SalesPersonID=R.SalesPersonID"})
CREATE (n667149422:FK{name:"FK_SalesOrderHeader_ShipMethod_ShipMethodID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Purchasing].[ShipMethod]",joinCondition:"P.ShipMethodID=R.ShipMethodID"})
CREATE (n683149479:FK{name:"FK_SalesOrderHeader_SalesTerritory_TerritoryID",parentObject:"[Sales].[SalesOrderHeader]",referencedObject:"[Sales].[SalesTerritory]",joinCondition:"P.TerritoryID=R.TerritoryID"})
CREATE (n699149536:FK{name:"FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID",parentObject:"[Sales].[SalesOrderHeaderSalesReason]",referencedObject:"[Sales].[SalesReason]",joinCondition:"P.SalesReasonID=R.SalesReasonID"})
CREATE (n715149593:FK{name:"FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID",parentObject:"[Sales].[SalesOrderHeaderSalesReason]",referencedObject:"[Sales].[SalesOrderHeader]",joinCondition:"P.SalesOrderID=R.SalesOrderID"})
CREATE (n731149650:FK{name:"FK_SalesPerson_Employee_SalesPersonID",parentObject:"[Sales].[SalesPerson]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.SalesPersonID=R.EmployeeID"})
CREATE (n747149707:FK{name:"FK_SalesPerson_SalesTerritory_TerritoryID",parentObject:"[Sales].[SalesPerson]",referencedObject:"[Sales].[SalesTerritory]",joinCondition:"P.TerritoryID=R.TerritoryID"})
CREATE (n763149764:FK{name:"FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID",parentObject:"[Sales].[SalesPersonQuotaHistory]",referencedObject:"[Sales].[SalesPerson]",joinCondition:"P.SalesPersonID=R.SalesPersonID"})
CREATE (n779149821:FK{name:"FK_SalesTaxRate_StateProvince_StateProvinceID",parentObject:"[Sales].[SalesTaxRate]",referencedObject:"[Person].[StateProvince]",joinCondition:"P.StateProvinceID=R.StateProvinceID"})
CREATE (n795149878:FK{name:"FK_SalesTerritoryHistory_SalesPerson_SalesPersonID",parentObject:"[Sales].[SalesTerritoryHistory]",referencedObject:"[Sales].[SalesPerson]",joinCondition:"P.SalesPersonID=R.SalesPersonID"})
CREATE (n811149935:FK{name:"FK_SalesTerritoryHistory_SalesTerritory_TerritoryID",parentObject:"[Sales].[SalesTerritoryHistory]",referencedObject:"[Sales].[SalesTerritory]",joinCondition:"P.TerritoryID=R.TerritoryID"})
CREATE (n827149992:FK{name:"FK_ShoppingCartItem_Product_ProductID",parentObject:"[Sales].[ShoppingCartItem]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n843150049:FK{name:"FK_SpecialOfferProduct_Product_ProductID",parentObject:"[Sales].[SpecialOfferProduct]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n859150106:FK{name:"FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID",parentObject:"[Sales].[SpecialOfferProduct]",referencedObject:"[Sales].[SpecialOffer]",joinCondition:"P.SpecialOfferID=R.SpecialOfferID"})
CREATE (n875150163:FK{name:"FK_StateProvince_CountryRegion_CountryRegionCode",parentObject:"[Person].[StateProvince]",referencedObject:"[Person].[CountryRegion]",joinCondition:"P.CountryRegionCode=R.CountryRegionCode"})
CREATE (n891150220:FK{name:"FK_StateProvince_SalesTerritory_TerritoryID",parentObject:"[Person].[StateProvince]",referencedObject:"[Sales].[SalesTerritory]",joinCondition:"P.TerritoryID=R.TerritoryID"})
CREATE (n907150277:FK{name:"FK_Store_Customer_CustomerID",parentObject:"[Sales].[Store]",referencedObject:"[Sales].[Customer]",joinCondition:"P.CustomerID=R.CustomerID"})
CREATE (n923150334:FK{name:"FK_Store_SalesPerson_SalesPersonID",parentObject:"[Sales].[Store]",referencedObject:"[Sales].[SalesPerson]",joinCondition:"P.SalesPersonID=R.SalesPersonID"})
CREATE (n939150391:FK{name:"FK_StoreContact_Contact_ContactID",parentObject:"[Sales].[StoreContact]",referencedObject:"[Person].[Contact]",joinCondition:"P.ContactID=R.ContactID"})
CREATE (n955150448:FK{name:"FK_StoreContact_ContactType_ContactTypeID",parentObject:"[Sales].[StoreContact]",referencedObject:"[Person].[ContactType]",joinCondition:"P.ContactTypeID=R.ContactTypeID"})
CREATE (n971150505:FK{name:"FK_StoreContact_Store_CustomerID",parentObject:"[Sales].[StoreContact]",referencedObject:"[Sales].[Store]",joinCondition:"P.CustomerID=R.CustomerID"})
CREATE (n987150562:FK{name:"FK_TransactionHistory_Product_ProductID",parentObject:"[Production].[TransactionHistory]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n1003150619:FK{name:"FK_VendorAddress_Address_AddressID",parentObject:"[Purchasing].[VendorAddress]",referencedObject:"[Person].[Address]",joinCondition:"P.AddressID=R.AddressID"})
CREATE (n1019150676:FK{name:"FK_VendorAddress_AddressType_AddressTypeID",parentObject:"[Purchasing].[VendorAddress]",referencedObject:"[Person].[AddressType]",joinCondition:"P.AddressTypeID=R.AddressTypeID"})
CREATE (n1035150733:FK{name:"FK_VendorAddress_Vendor_VendorID",parentObject:"[Purchasing].[VendorAddress]",referencedObject:"[Purchasing].[Vendor]",joinCondition:"P.VendorID=R.VendorID"})
CREATE (n1051150790:FK{name:"FK_VendorContact_Contact_ContactID",parentObject:"[Purchasing].[VendorContact]",referencedObject:"[Person].[Contact]",joinCondition:"P.ContactID=R.ContactID"})
CREATE (n1067150847:FK{name:"FK_VendorContact_ContactType_ContactTypeID",parentObject:"[Purchasing].[VendorContact]",referencedObject:"[Person].[ContactType]",joinCondition:"P.ContactTypeID=R.ContactTypeID"})
CREATE (n1083150904:FK{name:"FK_VendorContact_Vendor_VendorID",parentObject:"[Purchasing].[VendorContact]",referencedObject:"[Purchasing].[Vendor]",joinCondition:"P.VendorID=R.VendorID"})
CREATE (n1099150961:FK{name:"FK_WorkOrder_Product_ProductID",parentObject:"[Production].[WorkOrder]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductID=R.ProductID"})
CREATE (n1115151018:FK{name:"FK_WorkOrder_ScrapReason_ScrapReasonID",parentObject:"[Production].[WorkOrder]",referencedObject:"[Production].[ScrapReason]",joinCondition:"P.ScrapReasonID=R.ScrapReasonID"})
CREATE (n1131151075:FK{name:"FK_WorkOrderRouting_Location_LocationID",parentObject:"[Production].[WorkOrderRouting]",referencedObject:"[Production].[Location]",joinCondition:"P.LocationID=R.LocationID"})
CREATE (n1147151132:FK{name:"FK_WorkOrderRouting_WorkOrder_WorkOrderID",parentObject:"[Production].[WorkOrderRouting]",referencedObject:"[Production].[WorkOrder]",joinCondition:"P.WorkOrderID=R.WorkOrderID"})
CREATE (n1838629593:FK{name:"FK_Address_StateProvince_StateProvinceID",parentObject:"[Person].[Address]",referencedObject:"[Person].[StateProvince]",joinCondition:"P.StateProvinceID=R.StateProvinceID"})
CREATE (n1854629650:FK{name:"FK_BillOfMaterials_Product_ProductAssemblyID",parentObject:"[Production].[BillOfMaterials]",referencedObject:"[Production].[Product]",joinCondition:"P.ProductAssemblyID=R.ProductID"})
CREATE (n1870629707:FK{name:"FK_BillOfMaterials_Product_ComponentID",parentObject:"[Production].[BillOfMaterials]",referencedObject:"[Production].[Product]",joinCondition:"P.ComponentID=R.ProductID"})
CREATE (n1886629764:FK{name:"FK_BillOfMaterials_UnitMeasure_UnitMeasureCode",parentObject:"[Production].[BillOfMaterials]",referencedObject:"[Production].[UnitMeasure]",joinCondition:"P.UnitMeasureCode=R.UnitMeasureCode"})
CREATE (n1902629821:FK{name:"FK_ContactCreditCard_Contact_ContactID",parentObject:"[Sales].[ContactCreditCard]",referencedObject:"[Person].[Contact]",joinCondition:"P.ContactID=R.ContactID"})
CREATE (n1918629878:FK{name:"FK_ContactCreditCard_CreditCard_CreditCardID",parentObject:"[Sales].[ContactCreditCard]",referencedObject:"[Sales].[CreditCard]",joinCondition:"P.CreditCardID=R.CreditCardID"})
CREATE (n1934629935:FK{name:"FK_CountryRegionCurrency_CountryRegion_CountryRegionCode",parentObject:"[Sales].[CountryRegionCurrency]",referencedObject:"[Person].[CountryRegion]",joinCondition:"P.CountryRegionCode=R.CountryRegionCode"})
CREATE (n1950629992:FK{name:"FK_CountryRegionCurrency_Currency_CurrencyCode",parentObject:"[Sales].[CountryRegionCurrency]",referencedObject:"[Sales].[Currency]",joinCondition:"P.CurrencyCode=R.CurrencyCode"})
CREATE (n1966630049:FK{name:"FK_CurrencyRate_Currency_FromCurrencyCode",parentObject:"[Sales].[CurrencyRate]",referencedObject:"[Sales].[Currency]",joinCondition:"P.FromCurrencyCode=R.CurrencyCode"})
CREATE (n1982630106:FK{name:"FK_CurrencyRate_Currency_ToCurrencyCode",parentObject:"[Sales].[CurrencyRate]",referencedObject:"[Sales].[Currency]",joinCondition:"P.ToCurrencyCode=R.CurrencyCode"})
CREATE (n1998630163:FK{name:"FK_Customer_SalesTerritory_TerritoryID",parentObject:"[Sales].[Customer]",referencedObject:"[Sales].[SalesTerritory]",joinCondition:"P.TerritoryID=R.TerritoryID"})
CREATE (n2014630220:FK{name:"FK_CustomerAddress_Address_AddressID",parentObject:"[Sales].[CustomerAddress]",referencedObject:"[Person].[Address]",joinCondition:"P.AddressID=R.AddressID"})
CREATE (n2030630277:FK{name:"FK_CustomerAddress_AddressType_AddressTypeID",parentObject:"[Sales].[CustomerAddress]",referencedObject:"[Person].[AddressType]",joinCondition:"P.AddressTypeID=R.AddressTypeID"})
CREATE (n2046630334:FK{name:"FK_CustomerAddress_Customer_CustomerID",parentObject:"[Sales].[CustomerAddress]",referencedObject:"[Sales].[Customer]",joinCondition:"P.CustomerID=R.CustomerID"})
CREATE (n2062630391:FK{name:"FK_Employee_Employee_ManagerID",parentObject:"[HumanResources].[Employee]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.ManagerID=R.EmployeeID"})
CREATE (n2078630448:FK{name:"FK_Employee_Contact_ContactID",parentObject:"[HumanResources].[Employee]",referencedObject:"[Person].[Contact]",joinCondition:"P.ContactID=R.ContactID"})
CREATE (n2094630505:FK{name:"FK_EmployeeAddress_Address_AddressID",parentObject:"[HumanResources].[EmployeeAddress]",referencedObject:"[Person].[Address]",joinCondition:"P.AddressID=R.AddressID"})
CREATE (n2110630562:FK{name:"FK_EmployeeAddress_Employee_EmployeeID",parentObject:"[HumanResources].[EmployeeAddress]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.EmployeeID=R.EmployeeID"})
CREATE (n2126630619:FK{name:"FK_EmployeeDepartmentHistory_Department_DepartmentID",parentObject:"[HumanResources].[EmployeeDepartmentHistory]",referencedObject:"[HumanResources].[Department]",joinCondition:"P.DepartmentID=R.DepartmentID"})
CREATE (n2142630676:FK{name:"FK_EmployeeDepartmentHistory_Employee_EmployeeID",parentObject:"[HumanResources].[EmployeeDepartmentHistory]",referencedObject:"[HumanResources].[Employee]",joinCondition:"P.EmployeeID=R.EmployeeID"})
CREATE (n1173579219)-[:IS_RELATED_TO]->(n1698105090)
CREATE (n1221579390)-[:IS_RELATED_TO]->(n917578307)
CREATE (n1317579732)-[:IS_RELATED_TO]->(n709577566)
CREATE (n1317579732)-[:IS_RELATED_TO]->(n357576312)
CREATE (n1349579846)-[:IS_RELATED_TO]->(n917578307)
CREATE (n1477580302)-[:IS_RELATED_TO]->(n286624064)
CREATE (n1477580302)-[:IS_RELATED_TO]->(n286624064)
CREATE (n1477580302)-[:IS_RELATED_TO]->(n2069582411)
CREATE (n1477580302)-[:IS_RELATED_TO]->(n178099675)
CREATE (n1765581328)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n1877581727)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n1877581727)-[:IS_RELATED_TO]->(n853578079)
CREATE (n1909581841)-[:IS_RELATED_TO]->(n1381579960)
CREATE (n1909581841)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n2005582183)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n2117582582)-[:IS_RELATED_TO]->(n2069582411)
CREATE (n2117582582)-[:IS_RELATED_TO]->(n1285579618)
CREATE (n2099048)-[:IS_RELATED_TO]->(n1829581556)
CREATE (n2099048)-[:IS_RELATED_TO]->(n613577224)
CREATE (n2099048)-[:IS_RELATED_TO]->(n2069582411)
CREATE (n66099276)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n66099276)-[:IS_RELATED_TO]->(n34099162)
CREATE (n114099447)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n178099675)-[:IS_RELATED_TO]->(n1717581157)
CREATE (n226099846)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n226099846)-[:IS_RELATED_TO]->(n286624064)
CREATE (n226099846)-[:IS_RELATED_TO]->(n318624178)
CREATE (n354100302)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n354100302)-[:IS_RELATED_TO]->(n450100644)
CREATE (n450100644)-[:IS_RELATED_TO]->(n917578307)
CREATE (n450100644)-[:IS_RELATED_TO]->(n318624178)
CREATE (n450100644)-[:IS_RELATED_TO]->(n1730105204)
CREATE (n658101385)-[:IS_RELATED_TO]->(n770101784)
CREATE (n658101385)-[:IS_RELATED_TO]->(n2066106401)
CREATE (n770101784)-[:IS_RELATED_TO]->(n101575400)
CREATE (n770101784)-[:IS_RELATED_TO]->(n101575400)
CREATE (n770101784)-[:IS_RELATED_TO]->(n357576312)
CREATE (n770101784)-[:IS_RELATED_TO]->(n581577110)
CREATE (n770101784)-[:IS_RELATED_TO]->(n677577452)
CREATE (n770101784)-[:IS_RELATED_TO]->(n709577566)
CREATE (n770101784)-[:IS_RELATED_TO]->(n1058102810)
CREATE (n770101784)-[:IS_RELATED_TO]->(n1730105204)
CREATE (n770101784)-[:IS_RELATED_TO]->(n1426104121)
CREATE (n1026102696)-[:IS_RELATED_TO]->(n1314103722)
CREATE (n1026102696)-[:IS_RELATED_TO]->(n770101784)
CREATE (n1058102810)-[:IS_RELATED_TO]->(n917578307)
CREATE (n1058102810)-[:IS_RELATED_TO]->(n1426104121)
CREATE (n1250103494)-[:IS_RELATED_TO]->(n1058102810)
CREATE (n1346103836)-[:IS_RELATED_TO]->(n2114106572)
CREATE (n1602104748)-[:IS_RELATED_TO]->(n1058102810)
CREATE (n1602104748)-[:IS_RELATED_TO]->(n1426104121)
CREATE (n1842105603)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n2066106401)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n2066106401)-[:IS_RELATED_TO]->(n1922105888)
CREATE (n2114106572)-[:IS_RELATED_TO]->(n549576996)
CREATE (n2114106572)-[:IS_RELATED_TO]->(n1426104121)
CREATE (n30623152)-[:IS_RELATED_TO]->(n709577566)
CREATE (n30623152)-[:IS_RELATED_TO]->(n1058102810)
CREATE (n78623323)-[:IS_RELATED_TO]->(n357576312)
CREATE (n78623323)-[:IS_RELATED_TO]->(n485576768)
CREATE (n78623323)-[:IS_RELATED_TO]->(n30623152)
CREATE (n126623494)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n398624463)-[:IS_RELATED_TO]->(n101575400)
CREATE (n398624463)-[:IS_RELATED_TO]->(n149575571)
CREATE (n398624463)-[:IS_RELATED_TO]->(n318624178)
CREATE (n430624577)-[:IS_RELATED_TO]->(n357576312)
CREATE (n430624577)-[:IS_RELATED_TO]->(n485576768)
CREATE (n430624577)-[:IS_RELATED_TO]->(n318624178)
CREATE (n462624691)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n462624691)-[:IS_RELATED_TO]->(n1666104976)
CREATE (n542624976)-[:IS_RELATED_TO]->(n1381579960)
CREATE (n542624976)-[:IS_RELATED_TO]->(n462624691)
CREATE (n101575400)-[:IS_RELATED_TO]->(n2114106572)
CREATE (n229575856)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n229575856)-[:IS_RELATED_TO]->(n1477580302)
CREATE (n229575856)-[:IS_RELATED_TO]->(n286624064)
CREATE (n453576654)-[:IS_RELATED_TO]->(n357576312)
CREATE (n453576654)-[:IS_RELATED_TO]->(n581577110)
CREATE (n517576882)-[:IS_RELATED_TO]->(n549576996)
CREATE (n517576882)-[:IS_RELATED_TO]->(n645577338)
CREATE (n677577452)-[:IS_RELATED_TO]->(n645577338)
CREATE (n677577452)-[:IS_RELATED_TO]->(n645577338)
CREATE (n709577566)-[:IS_RELATED_TO]->(n1426104121)
CREATE (n773577794)-[:IS_RELATED_TO]->(n101575400)
CREATE (n773577794)-[:IS_RELATED_TO]->(n149575571)
CREATE (n773577794)-[:IS_RELATED_TO]->(n709577566)
CREATE (n917578307)-[:IS_RELATED_TO]->(n917578307)
CREATE (n917578307)-[:IS_RELATED_TO]->(n357576312)
CREATE (n1125579048)-[:IS_RELATED_TO]->(n101575400)
CREATE (n1125579048)-[:IS_RELATED_TO]->(n917578307)
CREATE (n1173579219)-[:IS_RELATED_TO]->(n821577965)
CREATE (n1173579219)-[:IS_RELATED_TO]->(n917578307)
CREATE (n1173579219)-[:PARTICIPATES_IN]->(n11147085)
CREATE (n1221579390)-[:PARTICIPATES_IN]->(n27147142)
CREATE (n1317579732)-[:PARTICIPATES_IN]->(n43147199)
CREATE (n1317579732)-[:PARTICIPATES_IN]->(n59147256)
CREATE (n1349579846)-[:PARTICIPATES_IN]->(n75147313)
CREATE (n1477580302)-[:PARTICIPATES_IN]->(n91147370)
CREATE (n1477580302)-[:PARTICIPATES_IN]->(n107147427)
CREATE (n1477580302)-[:PARTICIPATES_IN]->(n123147484)
CREATE (n1477580302)-[:PARTICIPATES_IN]->(n139147541)
CREATE (n1765581328)-[:PARTICIPATES_IN]->(n155147598)
CREATE (n1877581727)-[:PARTICIPATES_IN]->(n171147655)
CREATE (n1877581727)-[:PARTICIPATES_IN]->(n187147712)
CREATE (n1909581841)-[:PARTICIPATES_IN]->(n203147769)
CREATE (n1909581841)-[:PARTICIPATES_IN]->(n219147826)
CREATE (n2005582183)-[:PARTICIPATES_IN]->(n235147883)
CREATE (n2117582582)-[:PARTICIPATES_IN]->(n251147940)
CREATE (n2117582582)-[:PARTICIPATES_IN]->(n267147997)
CREATE (n2099048)-[:PARTICIPATES_IN]->(n283148054)
CREATE (n2099048)-[:PARTICIPATES_IN]->(n299148111)
CREATE (n2099048)-[:PARTICIPATES_IN]->(n315148168)
CREATE (n66099276)-[:PARTICIPATES_IN]->(n331148225)
CREATE (n66099276)-[:PARTICIPATES_IN]->(n347148282)
CREATE (n114099447)-[:PARTICIPATES_IN]->(n363148339)
CREATE (n178099675)-[:PARTICIPATES_IN]->(n379148396)
CREATE (n226099846)-[:PARTICIPATES_IN]->(n395148453)
CREATE (n226099846)-[:PARTICIPATES_IN]->(n411148510)
CREATE (n226099846)-[:PARTICIPATES_IN]->(n427148567)
CREATE (n354100302)-[:PARTICIPATES_IN]->(n443148624)
CREATE (n354100302)-[:PARTICIPATES_IN]->(n459148681)
CREATE (n450100644)-[:PARTICIPATES_IN]->(n475148738)
CREATE (n450100644)-[:PARTICIPATES_IN]->(n491148795)
CREATE (n450100644)-[:PARTICIPATES_IN]->(n507148852)
CREATE (n658101385)-[:PARTICIPATES_IN]->(n523148909)
CREATE (n658101385)-[:PARTICIPATES_IN]->(n539148966)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n555149023)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n571149080)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n587149137)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n603149194)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n619149251)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n635149308)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n651149365)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n667149422)
CREATE (n770101784)-[:PARTICIPATES_IN]->(n683149479)
CREATE (n1026102696)-[:PARTICIPATES_IN]->(n699149536)
CREATE (n1026102696)-[:PARTICIPATES_IN]->(n715149593)
CREATE (n1058102810)-[:PARTICIPATES_IN]->(n731149650)
CREATE (n1058102810)-[:PARTICIPATES_IN]->(n747149707)
CREATE (n1250103494)-[:PARTICIPATES_IN]->(n763149764)
CREATE (n1346103836)-[:PARTICIPATES_IN]->(n779149821)
CREATE (n1602104748)-[:PARTICIPATES_IN]->(n795149878)
CREATE (n1602104748)-[:PARTICIPATES_IN]->(n811149935)
CREATE (n1842105603)-[:PARTICIPATES_IN]->(n827149992)
CREATE (n2066106401)-[:PARTICIPATES_IN]->(n843150049)
CREATE (n2066106401)-[:PARTICIPATES_IN]->(n859150106)
CREATE (n2114106572)-[:PARTICIPATES_IN]->(n875150163)
CREATE (n2114106572)-[:PARTICIPATES_IN]->(n891150220)
CREATE (n30623152)-[:PARTICIPATES_IN]->(n907150277)
CREATE (n30623152)-[:PARTICIPATES_IN]->(n923150334)
CREATE (n78623323)-[:PARTICIPATES_IN]->(n939150391)
CREATE (n78623323)-[:PARTICIPATES_IN]->(n955150448)
CREATE (n78623323)-[:PARTICIPATES_IN]->(n971150505)
CREATE (n126623494)-[:PARTICIPATES_IN]->(n987150562)
CREATE (n398624463)-[:PARTICIPATES_IN]->(n1003150619)
CREATE (n398624463)-[:PARTICIPATES_IN]->(n1019150676)
CREATE (n398624463)-[:PARTICIPATES_IN]->(n1035150733)
CREATE (n430624577)-[:PARTICIPATES_IN]->(n1051150790)
CREATE (n430624577)-[:PARTICIPATES_IN]->(n1067150847)
CREATE (n430624577)-[:PARTICIPATES_IN]->(n1083150904)
CREATE (n462624691)-[:PARTICIPATES_IN]->(n1099150961)
CREATE (n462624691)-[:PARTICIPATES_IN]->(n1115151018)
CREATE (n542624976)-[:PARTICIPATES_IN]->(n1131151075)
CREATE (n542624976)-[:PARTICIPATES_IN]->(n1147151132)
CREATE (n101575400)-[:PARTICIPATES_IN]->(n1838629593)
CREATE (n229575856)-[:PARTICIPATES_IN]->(n1854629650)
CREATE (n229575856)-[:PARTICIPATES_IN]->(n1870629707)
CREATE (n229575856)-[:PARTICIPATES_IN]->(n1886629764)
CREATE (n453576654)-[:PARTICIPATES_IN]->(n1902629821)
CREATE (n453576654)-[:PARTICIPATES_IN]->(n1918629878)
CREATE (n517576882)-[:PARTICIPATES_IN]->(n1934629935)
CREATE (n517576882)-[:PARTICIPATES_IN]->(n1950629992)
CREATE (n677577452)-[:PARTICIPATES_IN]->(n1966630049)
CREATE (n677577452)-[:PARTICIPATES_IN]->(n1982630106)
CREATE (n709577566)-[:PARTICIPATES_IN]->(n1998630163)
CREATE (n773577794)-[:PARTICIPATES_IN]->(n2014630220)
CREATE (n773577794)-[:PARTICIPATES_IN]->(n2030630277)
CREATE (n773577794)-[:PARTICIPATES_IN]->(n2046630334)
CREATE (n917578307)-[:PARTICIPATES_IN]->(n2062630391)
CREATE (n917578307)-[:PARTICIPATES_IN]->(n2078630448)
CREATE (n1125579048)-[:PARTICIPATES_IN]->(n2094630505)
CREATE (n1125579048)-[:PARTICIPATES_IN]->(n2110630562)
CREATE (n1173579219)-[:PARTICIPATES_IN]->(n2126630619)
CREATE (n1173579219)-[:PARTICIPATES_IN]->(n2142630676)
CREATE (n11147085)-[:REFERENCES]->(n1698105090)
CREATE (n27147142)-[:REFERENCES]->(n917578307)
CREATE (n43147199)-[:REFERENCES]->(n709577566)
CREATE (n59147256)-[:REFERENCES]->(n357576312)
CREATE (n75147313)-[:REFERENCES]->(n917578307)
CREATE (n91147370)-[:REFERENCES]->(n286624064)
CREATE (n107147427)-[:REFERENCES]->(n286624064)
CREATE (n123147484)-[:REFERENCES]->(n2069582411)
CREATE (n139147541)-[:REFERENCES]->(n178099675)
CREATE (n155147598)-[:REFERENCES]->(n1477580302)
CREATE (n171147655)-[:REFERENCES]->(n1477580302)
CREATE (n187147712)-[:REFERENCES]->(n853578079)
CREATE (n203147769)-[:REFERENCES]->(n1381579960)
CREATE (n219147826)-[:REFERENCES]->(n1477580302)
CREATE (n235147883)-[:REFERENCES]->(n1477580302)
CREATE (n251147940)-[:REFERENCES]->(n2069582411)
CREATE (n267147997)-[:REFERENCES]->(n1285579618)
CREATE (n283148054)-[:REFERENCES]->(n1829581556)
CREATE (n299148111)-[:REFERENCES]->(n613577224)
CREATE (n315148168)-[:REFERENCES]->(n2069582411)
CREATE (n331148225)-[:REFERENCES]->(n1477580302)
CREATE (n347148282)-[:REFERENCES]->(n34099162)
CREATE (n363148339)-[:REFERENCES]->(n1477580302)
CREATE (n379148396)-[:REFERENCES]->(n1717581157)
CREATE (n395148453)-[:REFERENCES]->(n1477580302)
CREATE (n411148510)-[:REFERENCES]->(n286624064)
CREATE (n427148567)-[:REFERENCES]->(n318624178)
CREATE (n443148624)-[:REFERENCES]->(n1477580302)
CREATE (n459148681)-[:REFERENCES]->(n450100644)
CREATE (n475148738)-[:REFERENCES]->(n917578307)
CREATE (n491148795)-[:REFERENCES]->(n318624178)
CREATE (n507148852)-[:REFERENCES]->(n1730105204)
CREATE (n523148909)-[:REFERENCES]->(n770101784)
CREATE (n539148966)-[:REFERENCES]->(n2066106401)
CREATE (n555149023)-[:REFERENCES]->(n101575400)
CREATE (n571149080)-[:REFERENCES]->(n101575400)
CREATE (n587149137)-[:REFERENCES]->(n357576312)
CREATE (n603149194)-[:REFERENCES]->(n581577110)
CREATE (n619149251)-[:REFERENCES]->(n677577452)
CREATE (n635149308)-[:REFERENCES]->(n709577566)
CREATE (n651149365)-[:REFERENCES]->(n1058102810)
CREATE (n667149422)-[:REFERENCES]->(n1730105204)
CREATE (n683149479)-[:REFERENCES]->(n1426104121)
CREATE (n699149536)-[:REFERENCES]->(n1314103722)
CREATE (n715149593)-[:REFERENCES]->(n770101784)
CREATE (n731149650)-[:REFERENCES]->(n917578307)
CREATE (n747149707)-[:REFERENCES]->(n1426104121)
CREATE (n763149764)-[:REFERENCES]->(n1058102810)
CREATE (n779149821)-[:REFERENCES]->(n2114106572)
CREATE (n795149878)-[:REFERENCES]->(n1058102810)
CREATE (n811149935)-[:REFERENCES]->(n1426104121)
CREATE (n827149992)-[:REFERENCES]->(n1477580302)
CREATE (n843150049)-[:REFERENCES]->(n1477580302)
CREATE (n859150106)-[:REFERENCES]->(n1922105888)
CREATE (n875150163)-[:REFERENCES]->(n549576996)
CREATE (n891150220)-[:REFERENCES]->(n1426104121)
CREATE (n907150277)-[:REFERENCES]->(n709577566)
CREATE (n923150334)-[:REFERENCES]->(n1058102810)
CREATE (n939150391)-[:REFERENCES]->(n357576312)
CREATE (n955150448)-[:REFERENCES]->(n485576768)
CREATE (n971150505)-[:REFERENCES]->(n30623152)
CREATE (n987150562)-[:REFERENCES]->(n1477580302)
CREATE (n1003150619)-[:REFERENCES]->(n101575400)
CREATE (n1019150676)-[:REFERENCES]->(n149575571)
CREATE (n1035150733)-[:REFERENCES]->(n318624178)
CREATE (n1051150790)-[:REFERENCES]->(n357576312)
CREATE (n1067150847)-[:REFERENCES]->(n485576768)
CREATE (n1083150904)-[:REFERENCES]->(n318624178)
CREATE (n1099150961)-[:REFERENCES]->(n1477580302)
CREATE (n1115151018)-[:REFERENCES]->(n1666104976)
CREATE (n1131151075)-[:REFERENCES]->(n1381579960)
CREATE (n1147151132)-[:REFERENCES]->(n462624691)
CREATE (n1838629593)-[:REFERENCES]->(n2114106572)
CREATE (n1854629650)-[:REFERENCES]->(n1477580302)
CREATE (n1870629707)-[:REFERENCES]->(n1477580302)
CREATE (n1886629764)-[:REFERENCES]->(n286624064)
CREATE (n1902629821)-[:REFERENCES]->(n357576312)
CREATE (n1918629878)-[:REFERENCES]->(n581577110)
CREATE (n1934629935)-[:REFERENCES]->(n549576996)
CREATE (n1950629992)-[:REFERENCES]->(n645577338)
CREATE (n1966630049)-[:REFERENCES]->(n645577338)
CREATE (n1982630106)-[:REFERENCES]->(n645577338)
CREATE (n1998630163)-[:REFERENCES]->(n1426104121)
CREATE (n2014630220)-[:REFERENCES]->(n101575400)
CREATE (n2030630277)-[:REFERENCES]->(n149575571)
CREATE (n2046630334)-[:REFERENCES]->(n709577566)
CREATE (n2062630391)-[:REFERENCES]->(n917578307)
CREATE (n2078630448)-[:REFERENCES]->(n357576312)
CREATE (n2094630505)-[:REFERENCES]->(n101575400)
CREATE (n2110630562)-[:REFERENCES]->(n917578307)
CREATE (n2126630619)-[:REFERENCES]->(n821577965)
CREATE (n2142630676)-[:REFERENCES]->(n917578307);

In some cases the joins within the schema of the data warehouse are obvious to the data analyst so they can chase the [:REFERENCES] relationships. In other cases naming conventions (the lack of) confound the analyst so they need additional information contained within the foreign keys.

Querying the graph

At its simplests the query below will find the shortest route between two "tables" which will always be down the "IS_RELATED_TO" relationship.

//Shortest DB relationship path
MATCH (startTable { name:"ScrapReason" }),(endTable { name:"SalesReason" }),
  p = shortestPath((startTable)-[*..15]-(endTable))
RETURN p

Of course, if we want to chase down the more detailed routes which include the foreign key nodes then we would change our query slightly.

//Shortest DB relationship path
MATCH (startTable { name:"ScrapReason" }),(endTable { name:"SalesReason" }),
  p = shortestPath((startTable)-[:PARTICIPATES_IN|:REFERENCES*..15]-(endTable))
RETURN p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment