[GSOC] Database API draft proposal
Piotr Szturmaj
bncrbme at jadamspam.pl
Sun Apr 3 10:28:49 PDT 2011
Fawzi Mohamed wrote:
> Looking more maybe I was a bit too harsh, if you define clearly the
> goals of your API then yes it might be a good project.
> The api doesn't have to be defined yet, but a more detailed definition
> of its goals should be there, maybe with code example of some usages.
> Questions that should be answered:
I know your response is'nt to me, but please let me answer these
questions from my point of view, based on my recent work on ddb.
> * support for static and dynamic types.
> how access of dynamic and static types differs, should be as little as
> possible, and definitely the access one uses for dynamic types should
> work without changes on static types
If you mean statically or dynamically typed data row then I can say my
DBRow support both.
> * class or struct for row object
I'm using struct, because I think row received from database is a value
type rather than reference. If one selects rows from one table then yes,
it is possible to do some referencing based on primary key, but anyway I
think updates should be done explicitly, because row could be deleted in
the meantime. In more complex queries, not all of selected rows are
materialized, i.e. they may be from computed columns, view columns,
aggregate functions and so on. Allocation overhead is also lower for
structs.
> * support for table specific classes?
Table specific classes may be written by user and somehow wrap
underlying row type.
> * reference to description of the table (to be able to get also dynamic
> types by column name, but avoid using too much memory for the structure)
My PostgreSQL client already supports that. Class PGCommand has member
"fields", which contain information about returned columns. You can even
check what columns will be returned from a query, before actually
executing it.
> * Nice to define table structure, and what happens if the db has another
> structure.
This is a problem for ORM, but at first, we need standard query API.
> * you want to support only access or also db creation and modification?
First, I'm preparing base "traditional" API. Then I want to write simple
object-relational mapping. I've already written some code that generated
CREATE TABLE for structs at compile time. Static typing of row fields is
very helpful here.
More information about the Digitalmars-d
mailing list