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,bf02c238a92156a3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Windows Ada database support. Date: Wed, 8 Dec 2004 21:22:20 +0100 Organization: cbb software GmbH Message-ID: <1bucyi24j39vb.14y21qffgez47.dlg@40tude.net> References: <5e3e03a7.0411240431.7e037a4e@posting.google.com> <11w2chxxtggn9.a442ecwtujd2$.dlg@40tude.net> <1jrbh30djhwuh$.cpwm02mv7d1d.dlg@40tude.net> <18u46qzjs6s8v.19927r9ay0kkh.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net +yMsbE7C6om8/86MkuOqDQVVX0miKGecmMcfr7SXLWm4mCqBI= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:6852 Date: 2004-12-08T21:22:20+01:00 List-Id: On Wed, 8 Dec 2004 15:52:17 +0000 (UTC), Georg Bauhaus wrote: > Ole-Hjalmar Kristensen wrote: >: He may just as well be thinking in terms of sets and relations. SQL is >: just a slightly clumsy way of conveying those thoughts to the DB >: engine :-) > > Yes, thanks. I was thinking about one of those tiny little > everyday problems, and how to solve it and how to employ Ada > .Containers as "middleware". The problem: > > "Declare an ordered selection of objects. Make it available" > > Objects may be either just fetched from the DB or they may be synthesized, > i.e. newly constructed from the DB (!), effectively establishing a type. > If a language supports EVAL, you can even construct the types at > at language level at run time. > > Omitting the ordering issue, a SETL2 expression demonstrates a > non-SQL solution: > > result := { [foo, bar] : > id in { R.key : R in S | R.key >= 100 and R.key <= 200 }, > bar = T(foo) | foo = id }; > > No trace of SQL, but I'm sure you can see the relation between > a SET programming language and SQL. Note the result set ;-) > This is working code, S and T are sets of tuples. > You may say that there are tuples and sets, iieek. But the in > computer programs you will have to work with some sort of > compound data at some level. > If you dislike the presence of tuples, ".key" is a selector. > R.key means the same as R(1). This allows you to build interfaces > so you don't have to see the tuples. > > Dmitry, what is your plan the other way round, i.e. how do you > make data related expressions for some nice higher level abstraction? You have cunningly formulated the problem so that there is no higher level! (:-)) There is either: for I in S'Range loop if S (I).Key in 100..200 then for J in T'Range loop if T (J).Foo = S (I).Key then Append (Result, S (I).Key, T (J).Foo); end if; end loop; end if; end loop; or you define "*" (product) for the type Table'Class (of S and T) + other operations to extract sets from the tables. But the question is why an application should always organize its data in a way which could require implementation these, very expensive, operations? Isn't it so that tabular view just forces global container operations? When we write in Ada we avoid global operations. How often you copy an array in Ada (except String<->Unbounded_String conversion (:-))? Merge two arrays? Isn't S and T just a two-dimensional array? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de