comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh+bauhaus@maps.futureapps.de>
Subject: Re: Generic Collection
Date: Tue, 08 May 2007 23:00:23 +0200
Date: 2007-05-08T23:00:12+02:00	[thread overview]
Message-ID: <1178658022.9164.17.camel@kartoffel> (raw)
In-Reply-To: <1178652593.006083.173150@l77g2000hsb.googlegroups.com>

On Tue, 2007-05-08 at 12:29 -0700, andrew wrote:

> I cannot say for sure if the "is a" relations aren't entirely
> artificial.  It seems to me it would work either way.  The difference
> for me is that I cannot visualize the composition you mentioned.

As you noted, I meant that "a tuple is a collection of attributes"
doesn't necessarily imply inheritance relationship; TUPLE doesn't have
to inherit from a type COLLECTION_OF_ATTRIBUTES.

I think there are various possibilities; RDB2 (below RDB) shows
types that have components of other types (that is, are composed :-)
but are otherwise unrelated.
Package RDB desclares "is a" relations in the sense you describe
by making the DB types be "a collection of" objects of "smaller"
types.


> So what you are saying is that the type Item in my example is the
> parameter you are talking about?

Erh, I guess so.

with Ada.Containers.Hashed_Sets;
with Data;

package RDB is

   use Ada;

   type DP is access Data.T'class;
   function compare(a, b: DP) return BOOLEAN;
   function hash(element: DP) return Containers.HASH_TYPE;


   subtype ATTRIBUTE is DP;

   package Attributes is new Containers.Hashed_Sets
     (ELEMENT_TYPE => ATTRIBUTE,
      hash => hash,
      equivalent_elements => compare);


   subtype TUPLE is Attributes.SET;
   function hash(element: TUPLE) return Containers.HASH_TYPE;


   package Tuples is new Containers.Hashed_Sets
     (ELEMENT_TYPE => TUPLE,
      hash => hash,
      equivalent_elements => Attributes."=",
      "=" => Attributes."=");


   subtype TABLE is Tuples.SET;
   function hash(element: TABLE) return Containers.HASH_TYPE;


   package Tables is new Containers.Hashed_Sets
     (ELEMENT_TYPE => TABLE,
      Hash => hash,
      equivalent_elements => Tuples."=",
      "=" => Tuples."=");

   -- ...

end RDB;


with Ada.Containers.Hashed_Sets;
with Data;

package RDB2 is

   use Ada;

   type DP is access Data.T'class;
   function compare(a, b: DP) return BOOLEAN;
   function hash(element: DP) return Containers.HASH_TYPE;


   subtype ATTRIBUTE is DP;

   package Attributes is new Containers.Hashed_Sets
     (ELEMENT_TYPE => ATTRIBUTE,
      hash => hash,
      equivalent_elements => compare);

   type TUPLE is
      record
         -- ...
         columns: Attributes.SET;
      end record;
   function compare(a, b: TUPLE) return BOOLEAN;
   function hash(element: TUPLE) return Containers.HASH_TYPE;


   package Tuples is new Containers.Hashed_Sets
     (ELEMENT_TYPE => TUPLE,
      hash => hash,
      equivalent_elements => compare);


   type TABLE is
      record
         -- ...
         rows: Tuples.SET;
      end record;
   function compare(a, b: TABLE) return BOOLEAN;
   function hash(element: TABLE) return Containers.HASH_TYPE;


   package Tables is new Containers.Hashed_Sets
     (ELEMENT_TYPE => TABLE,
      Hash => hash,
      equivalent_elements => compare);

   type SCHEMA is
      record
         -- ...
         relations: Tables.SET;
      end record;


end RDB2;





  reply	other threads:[~2007-05-08 21:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-08 19:29 Generic Collection andrew
2007-05-08 21:00 ` Georg Bauhaus [this message]
2007-05-08 21:59   ` andrew
2007-05-09 14:51     ` andrew
2007-05-09 16:12       ` Georg Bauhaus
2007-05-09 18:54         ` andrew
2007-05-10 19:31           ` Simon Wright
2007-05-10 22:48             ` andrew
2007-05-11  8:10               ` Georg Bauhaus
2007-05-11 20:41                 ` andrew
2007-05-11 21:28                   ` Georg Bauhaus
2007-05-11 21:55                     ` andrew
2007-05-12  7:18               ` Simon Wright
2007-05-12  7:52                 ` Dmitry A. Kazakov
2007-05-13 11:00                   ` Simon Wright
2007-05-13 12:11                     ` Dmitry A. Kazakov
2007-05-16  0:27                     ` Randy Brukardt
2007-05-16  6:05                       ` Simon Wright
2007-05-16  7:17                         ` Untagged types don't work right - was: " Grein, Christoph (Fa. ESG)
2007-05-16 13:27                       ` Benjamin Place
2007-05-14 17:09                 ` andrew
2007-05-14 20:00                   ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox