Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Xbase commands Vrs Sql commands
Message
From
10/05/2005 13:06:42
 
 
To
10/05/2005 12:37:41
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01011885
Message ID:
01012492
Views:
19
>>Another example where sql is out of the game:
>>Build a database where the data they represent a connected graph ( not a treeview ).
>>Now, tries to extract the set of all row paths between two points with SQL commands.
>
>Known as the "travelling salesman problem"?
>
>Interesting. How do you represent the graph in your database and why is sql out of the game then?
>

If the nodes are homogenous
- a node it is a row of a table
then it is simple:
a table Arches with 3 columns
id is PK, RKid, FKid where (RKid, FKid) is candidate

try
CREATE CURSOR nodes (id I DEFAULT RECCOUNT()+1, tx c(20) DEFAULT TRANSFORM(id,"@R Nodes99999"))
FOR k=1 TO 5
	APPEND BLANK
NEXT
CREATE CURSOR Arches (id I,RKid I,FKid I)
INSERT INTO Arches (1,1,1)
INSERT INTO Arches (1,2,2)
INSERT INTO Arches (1,5,5)
INSERT INTO Arches (1,1,2)
INSERT INTO Arches (1,2,4)
INSERT INTO Arches (1,1,3)
INSERT INTO Arches (1,1,5)
INSERT INTO Arches (1,5,3)
INSERT INTO Arches (1,4,5)

* write a selects program that return the cursor PathNodes(1,5)=[1,2,4,5]
>Bye, Olaf.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform