dbTalk Databases Forums  

Demo: Modelling Cost of Travel Paths Between Towns

comp.databases.object comp.databases.object


Discuss Demo: Modelling Cost of Travel Paths Between Towns in the comp.databases.object forum.



Reply
 
Thread Tools Display Modes
  #41  
Old   
Nick Landsberg
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 12:48 PM






Laconic2 wrote:

Quote:
"Rok Debeljak" <rok.debeljak (AT) milenij (DOT) si.remove> wrote in message
news:Ru2ld.5529$F6.1282471 (AT) news (DOT) siol.net...

Here are the two times:


2004.11.11 24:00
2005.11.12 00:00
...
If a computation happened to result in 2004.11.11 24:00, I would
want it to
convert it to 2005.11.12 00:00. And I would call this final step

One year up or down does not really make any difference for a comparator
that really understands what we are talking about ;-)

Rokson



Ouch!!!! Of all the typos I've ever made, this is the worst. I don't know
how I missed it. My proofreading skills are going down the drain!

Let me try the whole thing over again, corrected:



According to ISO, we can assign the value 0000 or 2400 to midnight. Let's
look at another time, say 2 PM, or 1400 . Do we assign two values to 1400?



Believe it or not, this is a problem in "normalization". Not "data
normalization" as we ordinarily speak of it in database discussions, but
normalization nonetheless.

Let's say that we are given two times, and asked whether they are equal or
not.

Here are the two times:

2004.11.11 24:00
2004.11.12 00:00

The above form is for illustration purposes only.

Now a naive comparator would answer the question "no". But a comparator
that really understands what we are talking about
might take a closer look, and come up with the answer: "yes". I like the
answer "yes", myself, better.

In fact, I would like the "time type engine" whenever it's done some
calculation on time, (like adding an "interval" to a "base time") to
perform one final step, before delivering the result to the outside world.
If a computation happened to result in 2004.11.11 24:00, I would want it
to
convert it to 2004.11.12 00:00. And I would call this final step
"normalizing the result".

Once the results of a computation have been "normalized" , a naive
comparator
can test for equality by just comparing the representations. Right?





Actually, IMO, this makes a strong argument for storing times
internally as a certain number of "clock-ticks" since an "epoch".

Then the question reduces itself as to how to represent the
instance of time which is "midnight" - 2400 hours or 0000 hours?

NPL

--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch


Reply With Quote
  #42  
Old   
Laconic2
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 02:01 PM







"Ja Lar" <ingen (AT) mail (DOT) her> wrote



Quote:
I was considering a type (-engine?) as "DATETIME". An attribute of this
type
holds values that may be represented in various ways, but the VALUE
doesn't
depend on HOW it is represented to "the outside world" (and neither should
a
comparator on that type). Just nit-picking again <g>.
(For reference and to educate myself: where can I find your term "type
engine" defined as you use it?)
I don't have a formal definition. I was just picking up on the term as I
saw it used in this newsgroup.


But maybe this will help: when I tried to distinguish between the "naive
comparator" and the "intelligent comparator"
my point was precisely that the naive comparator compares representations,
while the intelligent comparator compares values. Maybe "aware comparator"
would have been better than "intelligent comparator"

Thus the question 2004.11.11.24.00 =? 2004.11.12.00.00 is "no" when you
compare the representations, but "yes" when you compare the values. This
is why engines that allow user defined datatypes require the definer to
supply the comparator.

I don't think this is very educative, and there's probably a better way to
say it. But this is the best I can come up with.

Ideally, there is a 1 for 1 homomorphism between representations and values.
When it isn't 1 for 1 it behooves us to normalize, if a given value has
more than one representation, and it really behooves us to disambiguate if
a single representation stands for more than one value. Does this settle
the matter?





Reply With Quote
  #43  
Old   
Ja Lar
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 02:41 PM




"Laconic2" <laconic2 (AT) comcast (DOT) net> skrev i en meddelelse
news:xJCdnVoISasXiwjcRVn-gA (AT) comcast (DOT) com...
Quote:
"Ja Lar" <ingen (AT) mail (DOT) her> wrote in message
news:4194ed13$0$245$edfadb0f (AT) dread11 (DOT) news.tele.dk...


I was considering a type (-engine?) as "DATETIME". An attribute of this
type
holds values that may be represented in various ways, but the VALUE
doesn't
depend on HOW it is represented to "the outside world" (and neither
should
a
comparator on that type). Just nit-picking again <g>.
(For reference and to educate myself: where can I find your term "type
engine" defined as you use it?)

I don't have a formal definition. I was just picking up on the term as I
saw it used in this newsgroup.


But maybe this will help: when I tried to distinguish between the "naive
comparator" and the "intelligent comparator"
my point was precisely that the naive comparator compares representations,
while the intelligent comparator compares values. Maybe "aware
comparator"
would have been better than "intelligent comparator"

Thus the question 2004.11.11.24.00 =? 2004.11.12.00.00 is "no" when you
compare the representations, but "yes" when you compare the values.
This
is why engines that allow user defined datatypes require the definer to
supply the comparator.

I don't think this is very educative, and there's probably a better way
to
say it. But this is the best I can come up with.

Ideally, there is a 1 for 1 homomorphism between representations and
values.
When it isn't 1 for 1 it behooves us to normalize, if a given value has
more than one representation, and it really behooves us to disambiguate
if
a single representation stands for more than one value. Does this settle
the matter?

I think I understand what you mean, and from a practical view I can follow
you.
(but I don't care if, or not, there is a 1-1 between value and
representation - I know no case where that's the case! Do you have an
example?)

The "matter" was: what is a "type engine". You defined it (loosely) as a
feature that returns a representation of a value (of the type).
That surprises me- I would expect that it created a value of the type, or
(better) created a new type (as in CREATE DOMAIN).
Is it not the latter you in fact refer to in your statement: "this is why
engines that allow user defined datatypes..."?
I.e.: "type engine" = "engine that allows user defined datatypes", rather
than "type engine" = "engine that returns representation of values"

But now we are _really_ far OT in this thread. I'm inclined to leave it
here.







Reply With Quote
  #44  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 04:54 PM



Quote:
In RM's current solution, symbol and town name are the same thing
resulting in inflexiblity in above case. In XDb2's solutions a symbol
or string names a town which is a different thing than the symbol or
string. RM has its own advantages which I did not list here.

What you are not realizing is that "town" would never be a Primary Key, so
it is easy in the RM to have more than one town with the same name. No big
deal.
True in general, but not when using the one-table schema provided by
Mr. Celko. Please show how the current RM solution can work if two
towns are named the same (ie change name of town c to a).


Reply With Quote
  #45  
Old   
frosty
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 05:37 PM



Nick Landsberg wrote:
Quote:
Then the question reduces itself as to how to represent the
instance of time which is "midnight" - 2400 hours or 0000 hours?

NPL
I've heard people say "twenty-four hundred hours."
I've never heard anyone say "zero hundred hours."

Maybe 00:00 is "midnight am," and 24:00 is "midnight pm."

--
frosty




Reply With Quote
  #46  
Old   
Nick Landsberg
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 06:57 PM



frosty wrote:

Quote:
Nick Landsberg wrote:

Then the question reduces itself as to how to represent the
instance of time which is "midnight" - 2400 hours or 0000 hours?

NPL


I've heard people say "twenty-four hundred hours."
I've never heard anyone say "zero hundred hours."

Maybe 00:00 is "midnight am," and 24:00 is "midnight pm."

Normal usage, as far as I can recall, is the "2400 hours"

However, I am not (recently) familiar with usage for
"one minute past midnight" ... I used to know it as
"zero, zero hours and zero one minutes"

NPL

--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch


Reply With Quote
  #47  
Old   
Alan
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-12-2004 , 08:37 PM




"Neo" <neo55592 (AT) hotmail (DOT) com> wrote

Quote:
In RM's current solution, symbol and town name are the same thing
resulting in inflexiblity in above case. In XDb2's solutions a symbol
or string names a town which is a different thing than the symbol or
string. RM has its own advantages which I did not list here.

What you are not realizing is that "town" would never be a Primary Key,
so
it is easy in the RM to have more than one town with the same name. No
big
deal.

True in general, but not when using the one-table schema provided by
Mr. Celko. Please show how the current RM solution can work if two
towns are named the same (ie change name of town c to a).
First of all, towns almost never change names. The two that come to mind in
the last 50 years in the U.S. are Tucumcari, NM to Truth or Consequences,
NM, and Levittown, NJ to Willingboro, NJ. Anyway, there are several ways,
depending on what you are modeling, but let's assume we are modeling U.S.
towns. The table would be thus:

town PK
state PK
main_postal_code PK
(Every town and city has a "main" post office. In Philadelphia, PA, which
has, I don't know, maybe 52 zip codes, the main post office is 19104 (there
is a 19101, 02, and 03, but they are not the "main" post office)). So, the
data for Philadlphia, PA would be:

Philadelphia PA 19104

Huh? New information just in? There's suddenly another Philadelphia in PA
(Happens a lot with Springfield. Many states have more than one.)

Add a row

Philadelphia PA 18952

What's that you say? The 19104 town name has changed to Neodelphia so as to
not confuse you? Well, first, you may want to capture the date this
occurred, so I would add a column (or two, depending)

start_date
end_date

So, now, we'd have data something like:

Philadelphia PA 19104 6/1/1682 11/12/2004
Neodelphia PA 19104 11/12/2004 12/31/2999

There is no problem, as much as you would like to have one to solve. And,
no- storing PA twice is not redundant. It is part of the PK, and being so,
helps to uniquely identify the town, so is therefore critical information.




Reply With Quote
  #48  
Old   
Laconic2
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-13-2004 , 06:26 AM




"Alan" <not.me (AT) uhuh (DOT) rcn.com> wrote


Just as an aside, towns do not change their name at will. At least not in
my state. Cities and towns are creations of the state. Their charter names
them. To change the name of a town requires state approval.

This makes it possible, at least in theory, for New Mexico to prevent the
occurrence of two cities or towns named, "Roswell".




Reply With Quote
  #49  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-13-2004 , 01:03 PM



Quote:
In RM's current solution, symbol and town name are the same thing
resulting in inflexiblity in above case. In XDb2's solutions a symbol
or string names a town which is a different thing than the symbol...

What you are not realizing is that "town" would never be a Primary Key,
so it is easy in the RM to have more than one town with the same name.

True in general, but not when using the one-table schema provided by
Mr. Celko. Please show how the current RM solution can work if two
towns are named the same (ie change name of town c to a).

town PK
state PK
main_postal_code PK
start_date
end_date
Thanks for demonstrating that Mr. Celko original schema does not
handle two towns with the same name without schema changes.

Quote:
Philadelphia PA 19104 6/1/1682 11/12/2004
Neodelphia PA 19104 11/12/2004 12/31/2999

And, no - storing PA twice is not redundant.
Storing any thing (ie PA) twice is redundant. On way to prove
redundancy is to change the second PA and see if data is corrupted
(without triggers/code to synchronize them). Also, if a property is
added to PA, will you add it the first PA, second PA, or both? I won't
be agruing the above point any further in this thread (unless you
bring out a new point) as it was already discussed at length in OT "A
Normalization Question".


Reply With Quote
  #50  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-13-2004 , 04:25 PM



On 13 Nov 2004 11:03:13 -0800, Neo wrote:

(snip)
Quote:
Philadelphia PA 19104 6/1/1682 11/12/2004
Neodelphia PA 19104 11/12/2004 12/31/2999

And, no - storing PA twice is not redundant.

Storing any thing (ie PA) twice is redundant.
Hi Neo,

A computer represents PA as a string of bits - either 16 or 32 bits on
most modern computers. If you store PA twice, you have the same string of
bits in two locations.

If you store PA once, you'll have to replace PA in the above rows with a
pointer to that location. A computer represents a pointer as a string of
bits - either 16 or 32 bits on most modern computers. So even if you store
PA once, you still end up with the same string of bits in two locations.


Quote:
On way to prove
redundancy is to change the second PA and see if data is corrupted
(without triggers/code to synchronize them).
Changes to the data should reflect changes in the reality. If PA state
boundaries are changed at the same moment that Philadelphia is renamed to
Neodelphia, changing the second PA would in fact even be required.

Changing PA when the state boundaries don't change will of course trash
your data, regardless of how you store it and how many times you store it.
Even if I had just one row of data and then change PA to IL, it'll still
be faulty.


Quote:
Also, if a property is
added to PA, will you add it the first PA, second PA, or both?
You are -once again- showing your total lack of comprehension of
normalization. If a propert is added to PA, it should be added in a
seperate table.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.