3

I'm very new to Graph database, so please ignore my mistakes. My scenario described in following picture:

enter image description here

I have different locations connected to each other with a route between them. Then I have many outlets linked to routes.

I created a RDBMS schema like this:

enter image description here

My data looks like this:

City linked City Routes Outlets

My goal is to give possible routes and outlets on them between two queried locations.

Recently I heard of Graph database support in SQL Server 2017 and read this article, but can't connect with my current problem.

Please help me to create Graph and node tables in SQL Server 2017.

Thanks!

Update

Now I create a data model:

Data Model

and some Node and Edge tables as follows:

CREATE TABLE [dbo].[mRoute](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](500) NOT NULL,
PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)ON [PRIMARY]
)
AS NODE ON [PRIMARY]
GO

CREATE TABLE [dbo].[mCity](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](500) NOT NULL,
PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)ON [PRIMARY]
)
AS NODE ON [PRIMARY]
GO

CREATE TABLE [dbo].[mOutlet](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](500) NOT NULL,
    [Latitude] [decimal](11, 9) NULL,
    [Longitude] [decimal](11, 9) NULL,
PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)ON [PRIMARY]
)
AS NODE ON [PRIMARY]
GO

CREATE TABLE [dbo].[On]
AS EDGE ON [PRIMARY]
GO

CREATE TABLE [dbo].[LinkedTo]
AS EDGE ON [PRIMARY]
GO

Now I am stuck on Between Edge Table, which contains route between two cities.

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
صفي
  • 1,068
  • 2
  • 15
  • 34
  • Should I move this post to https://dba.stackexchange.com/? – صفي Dec 04 '18 at 05:01
  • From the diagram I don't see a need to have LinkedCity and mOutlet database, they are redundant, just for your information! – Dipen Shah Dec 04 '18 at 19:14
  • Yes @DipenShah, you are right but for not `mOutlet` its `LinkedCity` and `mRoute` which are redundant. Thank for pointing out. – صفي Dec 05 '18 at 11:40

0 Answers0