Re: If you were developing a database in Forth...



MarkWills wrote:
Recently at work, my company burned £60,000 (~£120,000?) on 3
instances of SQL server. This to store the data from 66 subsea wells.

In fairness, they bought them, because that is the standard type of
solution that every supplies: Large, industrial grade SQL systems, but
I'm still left thinking "There has to be a better way" (VistaDB on
windows platforms offers a very affordable embeddable SQL database
with un-restricted licence policies).

This led me to wonder about the Forth approach. I'm still left
wondering though!

Well, as several people have pointed out, the appropriate approach could
vary wildly depending on the specific situation. So I don't think you
can expect more specific answers for such a wide-open question.

But I'll take a whack at it anyway. :)


First of all, I'd agree with several other people that the important
things aren't specific to Forth; they would be the same no matter what
language you use. It seems to me that implementing a classical
relational database well is a difficult task. And many Forth systems
these days have mostly functional FFI, so my first reaction would
probably be to call an existing library (MySQL, Postgresql, Berkley DB,
whatever), just as you might in C. You would probably have to create
bindings yourself, but that's usually a fairly trivial exercise. Just
start with the bits you need, and add more bindings later as necessary.

But assuming that's not acceptable for whatever reason...

For the purposes of this discussion, let's say that, in addition to a
method to input data, the database must provide some method of
querying the database. In order to reduce the amount of data returned
in a dataset, the software must be able to accept criteria as part of
it's query. However, there is no requirement to implement SQL, you are
free to come up with your own query language philosophy/design.

For a small database, you could conceivably just use Forth for the
criteria; iterate over all records, and have a place to plug in a piece
of code which determines whether the current record is part of the
desired set. But that could get slow pretty quickly on larger data
sets, so you would need indices. And then you would either have to
explicitly query the indices, or come up with a smarter query language
which could automagically figure out which indices apply.

Not really something specific to Forth, except that it may be useful to
have the interpreter available at runtime, whereas in C or some other
compiled language, you would have to start from scratch in that respect.

* How would data be persisted, and retrieved from a store?

Er...the same as in any other low-level language? There are words to
access files, or it may be appropriate to use blocks, especially if
you're running on the bare metal.

* Can the dictionary system in Forth be leveraged to advantage?

Possibly. It's basically just an associative array mapping names to
code and/or data. So if that's useful... Different systems have wildly
different degrees of access to the dictionary. You can always look up a
name and find the associated code/data. But whether you can iterate
over all names in the dictionary, or find an older value for a given
name...that's very implementation-specific.

* Lastly, how would other programs (let us say other Forth programs)
interface with this database in order to utilise it's facilities?

Well...if you can solve the problems of concurrent access, each program
could use the data from persistent storage. Or you could write a
database server and accept queries/data over connections of some kind;
then you could have the server only run one access at a time.


Hmm, yeah... I guess I don't have anything Forth-specific to say
either. Maybe you need a more specific question?

And...it's way past my bedtime, so hopefully this isn't utter nonsense.

--Josh
.



Relevant Pages

  • RE: Backups have Shadow Copy Problems
    ... and restarted the server. ... suggested and changed the recovery model to simple on the one database called ... I understand the issue to be: the backup task failed ... You back up data from a volume that contains a Microsoft SQL Server ...
    (microsoft.public.windows.server.sbs)
  • Re: upsizing to sql 2005
    ... the word SERVER in it, ... You can access to the database by multiple means (Access, ... and how does it update the SQL database with the new records in Access? ... Query Name: Arcadia - ARC ...
    (microsoft.public.access.queries)
  • Re: Linked Tables in Access
    ... any use of SQL Passthru, Linked Tables or any other use of MDB / MDE ... server, or would I also need to convert *those* queries to passthrough ... I've been trying to understand why Access database files become corrupt. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Leveling by ID vs. "Standard"
    ... of this trade called Project Management. ... a database for the "Project Tables," ... to write reports on data from the server database. ... product supporting queries created with SQL. ...
    (microsoft.public.project)
  • Re: Trouble Getting VS.Net 2003 WalkThroughs MSDE Connection
    ... Config Tool of SQL Server? ... > link to download the PUBs database. ... >>> Setup and they directed me to install MSDE and they attached a ...
    (microsoft.public.sqlserver.msde)