Arrays vs databases
mark at canelasoftware.com
Fri May 20 19:35:04 CEST 2016
> On May 20, 2016, at 12:53 AM, Matt Maier <blueback09 at gmail.com> wrote:
> I already know how to use Livecode and I think I can do everything I need
> using arrays.
> According to this lesson, I can store an array as a custom property of a
> stack which can be saved and loaded.
> Something I've done myself already is to either save the array as JSON in a
> text file or just as a binary with encode.
> So, in the most naive sense, it looks like I can have a key-value store
> without installing and learning anything new. But databases have extra
> functionality to deal with stuff like multiple simultaneous users, data
> integrity, and performance optimization.
> Can I just setup an instance of Livecode to act like an in-memory,
> key-value database? Maybe have a standalone stack act as the controller and
> have it mirror it's state in a separate stack that can be saved and loaded.
> I don't know enough about database design to frame the tradeoffs. Can
> someone who groks both Livecode and databases comment on this idea?
Using arrays to make your own key/value type database is very doable. The performance is probably indistinguishable with other databases for many types of apps. You can store data to disk easily with arrayEncode(); LSON as Richard has coined it.
The beauty of existing databases can not be ignored though. They do much more than store/retrieve data. Queries are one of the things that make databases so powerful.
Choosing the right path really depends on your needs. From my experience, LiveCode arrays make a fine database model for a wide range of applications. The best part is they are using a syntax you already know.
If you are interested in seeing a proof of concept you may want to try LiveCloud. It might give you some ideas on where to go if plan to make your own database. You are definitely embarking on a fun experience. I would suggest you explore it further.
More information about the use-livecode