Just to expand on this, I would suggest differentiating a
datastore from a
general use database.
Using LC's built in objects as a datastore is
eminently feasible, quick and easy. We all do this. However almost always, this will be tailored to the solution, and using this in other situations in ways not anticipated will be increasingly difficult and likely not as efficient.
A well tested database like SQLite on the other hand (hands down the commonest in-app database across
all programming languages), is extremely versatile, well tested and performant. It's nigh on impossible to break. SQL is an extremely versatile language that has been carefully crafted over the years to allow nearly any conceivable query and function relevant to the data.
My point being that a datastore is a very valid approach and may even be something that can be used across 1 developer's apps.
However to replicate the functionality of something like SQLite and make it generalisable to all developers in any conceivable scenario would be an extremely heavy undertaking and I doubt it would be as performant as just using SQLite.
-----------------------------------------------------------------------------------------------------------
However, there is no reason to be purist on how the data is
CRUD'd. I think what most would really care about is having a database accessible via 'normal' liveCodeScript.
Instead of rolling your own from scratch, a different approach may be to create an
intermediate library between the language and the database so you use for example liveCode native code and the library translates into something that drives SQLite or other chosen DBMS. This is a common design pattern in many languages and is often referred to as an
ORM (Object Relational Mapping).
There is
at least one LiveCode implementation of this as far as I know: Andre Garzia's
dbLib:
https://github.com/soapdog/livecode-dblib
I think
revIgniter may include something similar for server, and liveCloud implements it's own version of something similar - you can see the syntax here:
https://docs.livecloud.io.
Personally I find using a pure ORM a bit cumbersome and limiting because I'm relatively fluent in SQLite and would rather just use this for more complex actions. Plus, since SQL it very widely used across all languages, searching online for solution to a particular problem will invariably provide a result, as it would be extraordinary to conceive of a problem that hasn't already have been asked and answered.
No doubt a library like
dbLib suits many though - and as it's openSource you can freely download the source and modify it to your liking.
What I personally do is implement an intermediate library that implements some simpler commands in generic LC (eg
function getRecord pTable, pPrimaryKey -> returns an array for the record contained in table pTable for the record with primary key pPrimaryKey), as well as just allow complex SQL and return an array (eg
command doSQL pSQL, pParamArray -> executes SQL optional with a parameter array, and returns either outcome as a string or data as array in
the result).
The latter example doesn't really differ significantly in syntax from the built-in handlers, but I do this because the built in commands ether return a simple TSV, which is not usually suitable for my needs, or a database cursor, which still needs to move data into an LC usable format like an array so having this in a library just means I can keep my code leaner/cleaner.
It's still a work in progress that keeps changing with every project I create, but if I'm ever satisfied it's good enough to be used by anyone will likely just release it as openSource as well... along with this, I've been toying with creating something like the database browser in FileMaker Pro but sadly real life/work commitments have forced me to put that on the back burner for now.
So rather than investing time and effort in building a general use database from scratch, why not invest time in something like this? I'm sure may would want to contribute, so do consider putting it on GitHub where others can share code and submit features/fixes?