3 ms·
I have done both (basic) approaches and I find benefits in each. If I take the time to flesh out a project and either have a real DBA or at least put on my DBA
by ddtaylor 3y ago
I have done both (basic) approaches and I find benefits in each.
If I take the time to flesh out a project and either have a real DBA or at least put on my DBA hat for a day to come up with a proper set of SQL functions, views, etc. that expose everything nicely. That takes quite a while, but the results are good.
ORMs like SQLAlchemy (for Python) or RedBeanPHP (for PHP) can save a lot of time when making MVPs or just gluing together a couple of open source widgets. For these "quick hack" style things I really enjoy RedBeanPHP's fluid schema:
$bean = R::dispense('article');
$bean->title = "Foo";
$bean->body = "Bar! Bar!";
$bean->datePublished = R::isoDateTime();
R::store($bean);
That little snippet of code will automatically create a table `article` and the coorisponding columns `title`, `body`, and `date_published` all with their correct types (and type promotion if needed). If I later decide to add something new to articles I just do this:
$bean->whatDoesAiThink = $api->infer($bean->body);
This would automatically add the column `what_does_ai_think` to the schema.
All the automatic schema stuff can be disabled (ie. in production) via `R::freeze(true)`