![]() | |
#1
| |||
| |||
|
#2
| |||||
| |||||
|
|
www.xdb2.com/Example/Ex112.asp demos how to represent things needed to calculate the cost of traveling between any two towns via multiple paths. The example allows the path between any two towns to be uni or bi-directional. The example allows the specification of travel cost during any time period of each weekday. More specifically, the example represents the following things: Four towns named a, b, c, d (imagine them forming a square). There are paths from a to b, b to c, c to d and d to a. There are also opposite paths from a to d, d to c, c to b and b to a. In addition, there are two uni-directional cross paths, one from a to c and the second from b to d. The cost of travel from town a to town b on Monday between 00:00 and 24:00 is 1.00. |
|
The script below stores above things: // Create towns a, b, c, d CREATE2 *town.cls = thing; CREATE2 *a.cls = town; CREATE2 *b.cls = town; CREATE2 *c.cls = town; CREATE2 *d.cls = town; // Create directional verb "to" |
|
// which leads to lower level (aka creature) CREATE2 *goto.cls = verb; CREATE2 goto.vbType = cr; // Create a square shaped graph // Note: outer paths are bi-dir CREATE2 a.goto = b; CREATE2 b.goto = a; CREATE2 b.goto = c; CREATE2 c.goto = b; CREATE2 c.goto = d; CREATE2 d.to = c; |
|
CREATE2 d.goto = a; CREATE2 a.goto = d; // Note: inner cross paths are uni-dir CREATE2 a.goto = c; CREATE2 b.goto = d; |
|
// Create weekdays CREATE2 *weekday.cls = thing; // Create start time of day (inclusive) CREATE2 *start.cls = thing; // Create end time of day (exclusive) CREATE2 *end.cls = thing; // Create costs CREATE2 *cost.cls = thing; // Create it cost 1.00 to go from town a to town b // on monday between 00:00 and 24:00 CREATE2 (a.goto=b).weekday = +monday; CREATE2 ((a.goto=b).weekday=monday).start = +00:00; CREATE2 (((a.goto=b).weekday=monday).start=00:00).end = +24:00; CREATE2 ((((a.goto=b).weekday=monday).start=00:00).end=24: 00).cost = +1.00; |
#3
| |||||
| |||||
|
|
Alan wrote: Neo has stored the word "monday" 4 times. Neo has stored letters a, b, c, d more times than I care to count. Therefore, Neo is practicing redundancy. |
|
Neo has stored program code as data. |
|
Neo is practicing Object Orientation. |
|
What happens when trip goes to 64 towns in three months, visiting some towns more than once? Answer: Neo has stored big headache and carpal tunnel syndrome. |
|
Here is some SQL for Neo to learn: INSERT INTO neo VALUES 'common sense', 'integrity', 'honesty'; UPDATE neo SET pocketbook = pocketbook - 1000; |
#4
| ||||||
| ||||||
|
|
Alan wrote: Neo has stored the word "monday" 4 times. Neo has stored letters a, b, c, d more times than I care to count. Therefore, Neo is practicing redundancy. I do not assert the script to create the db does not have redundant things. I do assert that there are no redundant things in the db including the word "monday" and the symbols a, b, c, d. Example www.xdb2.com/Example/BoxProperties.asp demonstrates this ability by displaying the ID of symbol 1 and the quantity 1. I am surprised you didn't understand this as it was discussed and demonstrated at great length in the recent comp.database.theory thread titled "A Normalization Question" to which you were a significant contributor. Would you like to reverify step-by-step that there is only one word "monday" in the db? |
|
Neo has stored program code as data. Could you specify the program code that Neo stored as data. It appears you are against storing program code as data. Could you first define the fundamental difference between code and data. Could you then indicate why you are against storing "code" as data. Are you asserting that by storing the same things in a relational db, there would be no storing of program code as data? |
|
Neo is practicing Object Orientation. Could you please define what is an "object" and "object-orientation". In RM, tables, row, columns, values can be thought of as objects. Are you asserting that in the tools that you use, you are not practicing some level of object-orientation? |
|
What happens when trip goes to 64 towns in three months, visiting some towns more than once? Answer: Neo has stored big headache and carpal tunnel syndrome. Why don't we find out for sure. Would you be willing to model 64 towns with various paths, cost factors and valid durations in a week; and then query/code solutions to some typical problems to guage each methods advantages/disadvantages? |
|
that you prefer. |
|
Here is some SQL for Neo to learn: INSERT INTO neo VALUES 'common sense', 'integrity', 'honesty'; UPDATE neo SET pocketbook = pocketbook - 1000; Please teach Neo the common sense meaning of integrity and honesty by showing that Hugo's RM Solution #1 and #2 aren't nearly twice as slow as XDb1's even when XDb1 is executed on a 5.6X slower machine. |
#5
| |||
| |||
|
|
Could you specify the program code that Neo stored as data. It appears |
|
Please teach Neo the common sense meaning of integrity and honesty by |
#6
| |||
| |||
|
|
Please teach Neo the common sense meaning of integrity and honesty by |
#7
| |||
| |||
|
|
Four towns named a, b, c, d (imagine them forming a square). There are |
#8
| |||
| |||
|
|
That gets all the (travel_cost = 1) edges in the graph. Next, use Warshall's algorithm to fill in travel costs on ('c', 'a'), ('d', 'b') and so forth. This will work for any adjacency list model. I would do the matrix multiplications in a host language like FORTRAN, C or Pascal, but I can do it in pure SQL if I have to (see that section in SQL FOR SMARTIES). |
#9
| ||||||
| ||||||
|
|
Incomplete problem description. What is the costs for travel on other days? |
|
// Create directional verb "to" Documentation error. you actually created the verb "goto" |
|
CREATE2 c.goto = d; CREATE2 d.to = c; Compile error. no such method as "to" |
|
Actually all the so-called paths are unidirectional. You never created a bidirectional "goto" verb. |
|
// Create it cost 1.00 to go from town a to town b // on monday between 00:00 and 24:00 CREATE2 (a.goto=b).weekday = +monday; weird operators...is there such a thing as a negative monday? |
|
Now that you have a design, what problems do you think you can solve with it? (You are not really so uninformed as to suggest this might solve the travelling salesman problem, are you?) |
#10
| ||||
| ||||
|
|
Some tools (like Windows) are based on OO concepts. Others (like SQL) are not. |
|
Why don't you do it? All 64 towns. WIth a minimum of 4096 possibilities. |

|
I have no interest in attempting to solve this problem, just in pointing out that your "solution" is not a solution, and is bound to send anyone who tries it to the doctor. |
|
Here is some SQL for Neo to learn: INSERT INTO neo VALUES 'common sense', 'integrity', 'honesty'; UPDATE neo SET pocketbook = pocketbook - 1000; Please teach Neo the common sense meaning of integrity and honesty by showing that Hugo's RM Solution #1 and #2 aren't nearly twice as slow as XDb1's even when XDb1 is executed on a 5.6X slower machine. I don't have to. It's been done. Repeatedly. |
![]() |
| Thread Tools | |
| Display Modes | |
| |