From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86a457a80a9f4412 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!e51g2000hsg.googlegroups.com!not-for-mail From: andrew Newsgroups: comp.lang.ada Subject: Re: Generic Collection Date: 8 May 2007 14:59:46 -0700 Organization: http://groups.google.com Message-ID: <1178661586.585164.191690@e51g2000hsg.googlegroups.com> References: <1178652593.006083.173150@l77g2000hsb.googlegroups.com> <1178658022.9164.17.camel@kartoffel> NNTP-Posting-Host: 139.78.128.110 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1178661587 8763 127.0.0.1 (8 May 2007 21:59:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 May 2007 21:59:47 +0000 (UTC) In-Reply-To: <1178658022.9164.17.camel@kartoffel> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: e51g2000hsg.googlegroups.com; posting-host=139.78.128.110; posting-account=Kq9unQ0AAADh_grEViI3JGqegXKDDjxt Xref: g2news1.google.com comp.lang.ada:15666 Date: 2007-05-08T14:59:46-07:00 List-Id: On May 8, 4:00 pm, Georg Bauhaus wrote: > 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; RDB2 looks good to me and is pretty close to what I had in mind. I think I finally get what you were saying about inheritance. Before I posted the topic I was thinking about the design and I just wrote down the "table is a collection" as part of sentence. In my mind I was thinking of a variable declaration: table: collection; tuple: collection; schema: collection; and so I posted my question.