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,ccec7cf654f5e8c3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!news.wiretrip.org!border2.nntp.ams.giganews.com!nntp.giganews.com!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: creating database References: <1115570998.707181.84650@o13g2000cwo.googlegroups.com> From: Ludovic Brenta Date: Sun, 08 May 2005 19:36:00 +0200 Message-ID: <87sm0xmxhb.fsf@insalien.org> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:j0hL3FXQ2Gj7NstMQWB4IfkSYrs= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 08 May 2005 19:35:50 CEST NNTP-Posting-Host: 83.134.247.7 X-Trace: 1115573750 dreader2.news.tiscali.nl 1363 83.134.247.7:32770 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:10954 Date: 2005-05-08T19:35:50+02:00 List-Id: writes: > hi > > I'm trying to create a database using ada. I'm struggling to work > out how to implement the record type and storage. The data only has > to be stored in main memory. > > I was thinking of creating the ADT as a record with various fields, > and then an array with each element containing a record. However, I > don't know how many records there'll be so it seems inefficient to > declare an array of a particular size. > > Any advice one how to implement the database would be very much > appreciated. As an ada novice, I'm struggling. We do not do students' homework for them, so I'm not going to give you "the answer" here (if you're not a student, this sentence is intended for future readers who may be students). Your question is not specific to Ada or any particular language. It is a design question. If I understand well, you're trying to store a variable (and unknown at compile time) number of "things" in memory. There are many well-known data structures to choose from, or you could roll your own. The simplest data structure you can try is called a "linked list". Look it up on Google. A linked list is simple and efficient when adding new "things", but inefficient when searching for one particular "thing". Most industrial-strength database engines use more sophisticated data structures such as B-trees (q.v., on Google). HTH -- Ludovic.