An open API service indexing awesome lists of open source software.

https://github.com/skytecat/thecheapestroute_sql

SQL statement that returns the cheapest tour using a Recursive Query
https://github.com/skytecat/thecheapestroute_sql

postgresql sql

Last synced: over 1 year ago
JSON representation

SQL statement that returns the cheapest tour using a Recursive Query

Awesome Lists containing this project

README

          

# The cheapest route SQL

Описание на русском [тут](./README_RUS.md).

![graph](misc/images/graph.png)

# Technical assignment

Please take a look at the Graph. There are 4 cities (a, b, c and d) and arcs between them with cost (or taxination). Actually the cost (a,b) = (b,a).

Please write one SQL statement using Recursive Query that returns all tours (aka paths) with minimal traveling cost if we will start from city "a".

You need to find the cheapest way of visiting all the cities and returning to your starting point. For example, the tour looks like that a -> b -> c -> d -> a.
Please sort data by total_cost and then by tour.

# Instructions for running the code

Please download a script with Database Model from src/database/model.sql and apply the script to your database.

Run the script from src/the_cheapest_route.sql