Re: Does Codd's view of a relational database differ from that ofDate&Darwin?[M.Gittens]

From: Jon Heggland <heggland_at_idi.ntnu.no>
Date: Tue, 5 Jul 2005 23:17:24 +0200
Message-ID: <MPG.1d35174a7f9255929896e2_at_news.ntnu.no>


In article <1120578666.773825.118800_at_f14g2000cwb.googlegroups.com>, boston103_at_hotmail.com says...
> > Perhaps. The difference between representation and presentation is just
> > two letters. :) I think it is more convenient to define a single
> > Temperature domain, with possreps Celsius, Fahrenheit and Kelvin, than
> > to define three different domains, and make operators for converting
> > between them.
>
> It's an illusion ;) You still have to define three data types and then
> union them(see below).

No, I don't. :) See below.

> Here's an example in C:
>
> union my_data
> {
> char c;
> int i;
> float f;
> };
>
> x, y my_data;
>
> x.c='x';
> y.f=3.14;
> x=y;
> -- etc --

I'm still not clear on how this works. Do character, integer and float operators work on this union? What happens if you attempt to multiply x by y (before the assignment x=y)?

Here's an example in Java:

class Temperature
{
  private double celsius;

  public double getCelsius()    { return celsius; }
  public double getFahrenheit() { return celsius * 9 / 5 + 32; }
  public double getKelvin()     { return celsius + 273.15; }

  public void setCelsius(double c)    { celsius = c; }
  public void setFahrenheit(double f) { celsius = (f - 32) * 5 / 9; }
  public void setKelvin(double k)     { celsius = k - 273.15; }
}

> I am not sure that "possible representation" in TTM is a good name
> either. Why not use the established terminology and just call the
> whole construct a [disjoint] union type (as has been done in
> programming languages for ages) ? I may be missing some subtle
> difference betewen the u.t. the p.r., though.

I don't think union types are relevant. In C, you can say int i = 14; or int i = 0xE;---that does not mean int is a union type.

> I think that using the word "representation" is rather confusing. If a
> representation is just [one of constituent] data type[s], why not just
> say so ?

I don't think it is.

-- 
Jon
Received on Tue Jul 05 2005 - 23:17:24 CEST

Original text of this message