I'm glad you've liked it.
> That being said, after playing around I do have a few questions:
>
> * I notice when I add records via the api, I see them show up in the
> dbf, but if I delete the records directly from the dbf file and run a
> api select query they are gone. Shouldn't the data structure be
> independent of the file? I would have thought it would just log the
> occurrences to the dbf, but leave the actual data in memory. Otherwise
> it's not really an in memory-db, it's doing a file read every time -
> correct? To me, this means as the file becomes bigger the performance
> will degrade correct? Oddly, If I add a record to the file, not using
> the api it does not show up in select queries and the record is later
> removed from the file. Is this expected? Normal?
The behavior of FleeDB is undefined if you modify the .fdb file
yourself from under the database. You can always read it but should
never write it. I would expect that if you deleted a record from the
.fdb file and then reloaded the database then the record would not
appear. I'm not sure what to expect if you edited the file under a
running database; you just shouldn't do that.
> * I see, glancing at the code, you're writing to a tmp file then, upon
> completion, re-naming the file to replace the dbf. How atomic is this?
> At what point would there be concurrency conflicts?
> Do you have any
> guidance for what kind of projects this kind of a database system
> would be good for?
FleetDB is suitable for many types of projects. It is specifically
designed for those that need a powerful and flexible data model,
robust concurrency and durability stories, ease of use, and high
performance. Many "OLTP" type applications fit into this category,
though I have found FleetDB useful in other areas as well.
> * If durability is achieve via file writes would it not be best to
> leave the data in memory, then write a separate file for each record?
> Queries could go against the in-memory data-structure to be fast and
> file records just become over written (all small files). Not appended.
> Reboots could optionally load records (maybe even in a range).
FleetDB is designed to handle databases of up to at least 10s of
millions of records; that is too many records for a 1-file-per-record
persistence model.
> This is all really new to me so I could be missing the knowledge to
> know what's better, or even what's going on.
> Or maybe I've mucked up implementing it?
Thanks for sharing your thoughts and asking these questions. Let us
know if you have any others.
> Thanks,
> Tim
>
> P.S. Allowing values to be vectors or maps would be a great addition.
I'm strongly considering this for post 0.2.0. If you have specific use
cases in mind I'd love to hear about them as an aide to designing the
API.
Thanks,
- Mark
I expect to store hierarchical data with nested vectors and maps, but
FleetDB is already suitable for this when combined with Clojure's str
and read-string.
What I would find even more interesting is a query language that would
make it easy to extract hierarchical data from a table so that a bunch
of records like {:id 398752 :parent-id 9872367 :content "Node13"}
could be used to build a query result like
{:id 320857 :content "Node1"
:children [{:id 269364 :parent-id 320857 :content "Node2"}
{:id 9763655 :parent-id 320857 :content "Node3"
:children [{:id 67463 :parent-id 9763655 :content
"Node4"}]}]
Recursive queries? Move the query language towards resembling Scheme
more than SQL?
Anyway, I already love FleetDB and expect to use it for my next project.
Thanks for sharing this example. I can definitely see how records with
multi-valued attributes could be better supported in FleetDB.
- Mark
Yeah, full-text search would be a much more ambitious feature (: I've
thought about it before, but its not at the top of the list right now.
I'll let you know if start working on it though.
- Mark