Re: Is it possible to use a database though any high-level API?
Date: 12 Apr 2007 08:22:06 -0700
Message-ID: <1176391326.105368.270940_at_y5g2000hsa.googlegroups.com>
On Apr 12, 2:44 pm, beachmount..._at_hotmail.com wrote:
> Hi!
>
> I hope I am posting this in the correct group, I am quite new to
> usenet posting.
>
> I have only been working in the computer area for a couple of years,
> and my experience with databases is limited to a five week course
> during my education.
>
> As I think about an application I want to develop, I have a question
> about databases that I would love to have someone shine a light on.
>
> The question is, is there any programming tool available so that I do
> not need to contruct a database "by hand", that is, I would like to
> have an API to use so that I can easily store the implemented objects
> in my object-oriented solution without caring about how they are
> stored?
>
> It seems to me that it would be a perfect task for a computer to
> translate my objects into relational tables or some object-oriented
> representation. It seems redundant that I should have to create TWO
> models, one in the object-oriented implementation, and one for the
> database (for instance creating tables with columns and so on), when
> the two models are just different representations of the same objects
> and relations between objects (or am I totally wrong here?)
>
> Performance is not a big issue in this case.
>
> Are there any such tools, and if not, why not?
>
> I imagine myself using the tool somewhat like this:
>
> If I have two classes, Person and House, and a House can have one
> Person as an owner:
>
> Person bob = new Person("Bob")
> House castle = new House("Castle")
>
> castle.owner = bob
>
> (owner may for instance be a property, storing a reference to a Person
> object)
>
> To store the objects, it would be neat to use something like:
>
> MagicAPI.store(bob)
> MagicAPI.store(castle)
>
> without caring about "rows" or "columns" or even relational or obejct-
> oriented databases. (Of course somewhere there had to be information
> about exactly where and how to store things, but this would be simple
> configuration settings)
>
> To search it would be great to use som SQL like syntax like:
>
> listOfHouses = MagicAPI.find("House WHERE owner=bob")
>
> Or perhaps create a Find object from the MagicAPI, set all search
> criteria, and the invoke the find method of the Find object.
>
> I guess it would be neccessary to somehow explicitly define unique
> identifiers ("primary keys") to classes. Perhaps like this:
>
> MagicAPI.setUnique(Person, IDNumber)
>
> where IDNumber might be a property of the class Person representing
> the social security number. The API would then react if trying to add
> two persons with the same IDNumber.
>
> I know this example is simple, but I hope it illustrates the general
> idea of what I am looking for.
>
> I think it would be really nice if programming towards a database
> could be somewhat like programming againt a high level file API (e.g.
> from the OS). I often dont really care about how a file is stored on a
> bit level. As performance is not a big issue for me in this case, I
> dont really care how the database is implemented, as long as the
> database maintains the relationships between stored objects.
>
> Thank you in advance!
>
> /Fredrik Strandberg
Is it a curse or there always people trying to reinvent square wheels....
Hope this helps... Received on Thu Apr 12 2007 - 17:22:06 CEST