std.database

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 2 17:49:22 PST 2016


On Wed, 02 Mar 2016 15:41:56 +0000, Piotrek wrote:
> 3. What I call a D Database API could be described as:
>   - Database object
>   - DbCollection object (equivalent to array)
>   - ranges + std.algorithm

It looks like you're trying to write a LevelDB analogue that implements 
an array rather than a key/value collection -- and that's a decent start.

If you're trying to connect to a SQL database or a document database, as 
I'd expect for something called "std.database", it's a pretty terrible 
API:
 * No index scans, lookups, or range queries.
 * No support for complex queries.
 * No support for joins.
 * No support for projections.
 * No support for transactions.
 * If you add support for transactions, you'll crash all the time because 
the transactions got too large, thanks to the full table scan mentality.
 * In your implementation, updates must bring every affected row over the 
wire, then send back the modified row.
 * Updates affect an entire row. If one process updates one field in a 
row and another one updates a different field, one of those writes gets 
clobbered.
 * The API assumes a total ordering for each DbCollection. This is not 
valid.
 * If there are multiple rows that compare as equals, there's no way to 
update only one of them in your implementation.
 * In your implementation, updating one row is a ϴ(N) operation. It still 
costs ϴ(N) when the row you want to update is the first one in the 
collection.


More information about the Digitalmars-d mailing list