Live data from Hacker News

What if OpenDocument used SQLite? (2014)

sqlite.org

211–220 of 310 posts

Re: What if OpenDocument used SQLite? (2014)

#211
post #6

I'm currently working on an application where I use SQLite as the file format. I want to keep a usual workflow for users where you can make edit to your document and it only changes the file when you save it. So to open a file I copy it into the :memory: database [1], then the user can do whatever manipulation they want and I can directly make the change in the database I don't need to have a model of the document ot…

[deleted]

Re: What if OpenDocument used SQLite? (2014)

#212
Sqlite-based file formats are also very easy to debug, which saves a lot of dev time. After my app writes to a file and loading back doesn't work, I can just open it in Sqlite and inspect it in any way I wish because I have the full power of SQL at my fingertips.

Re: What if OpenDocument used SQLite? (2014)

#214

I shipped a product that used both SQLite and XML files. One of the improvements that I made was moving a few tables that contained small amounts of data to xml files. Because these files were small and rarely written; it simplified the data access layer, and simplified diagnostics. (I made sure the files were multi-line tabbed xml.) For "technical" people who needed to diagnose the product, asking them to crack open…

I'm unclear on how SQLite (native format, no zip) is achieving sizes similar to XML + Zip. Are SQLite TEXT or BLOB fields compressed? Or are they assuming the caller is compressing BLOBs before writing?

Re: What if OpenDocument used SQLite? (2014)

#215

Earlier quoted context omitted.

> Such a query either returns an undefined answer or generates an error in many other SQL database engines, but in SQLite it does what you would expect: It may be a useful functionality, but it is NOT what I would expect such a query to return, to be frank. Also you don't need a nested query in this specific, you can order by checkinTime and limit the result to one. > select manifest, versionId, checkinTime from vers…

I agree, that doesn't make sense to me either. What about select versionId, max(checkinTime), min(checkinTime)? Can as well query SqlGPT. And above all, it's not what the SQL standard says when that's the entire point of using a standard in the first place.

Well, it doesn't error out! In this example, it seems like it picks the result from whatever matches the last column, but not sure if this is determinstic:

    sqlite> create table x(c1, c2);
    sqlite> insert into x values ("a", 1);
    sqlite> insert into x values ("b", 2);
    sqlite> insert into x values ("c", 3);
    sqlite> select c1, max(c2) from x;
    c|3
    sqlite> select c1, max(c2), min(c2) from x;
    a|3|1
    sqlite> select c1, min(c2), max(c2) from x;
    c|1|3
(note: since SQLite is dynamically typed, no need to specify column types for simple examples like this).

Re: What if OpenDocument used SQLite? (2014)

#216
post #85

Sqlite format is smaller than the original format only because xml is super verbose, so any uncompressed binary format ends up being less than lightly zipped xml. But sqlite files aren't small. One thing I don't understand is why they don't do string deduplication in sqlite (as in you only store a string once and every other occurence is just a pointer to that string). It seems such an obvious and easy way to reduce…

If you have the same (long-ish) string repeating many times in a database, it points to a DB schema needing normalization.

I guess it depends on the use case. If you load a csv file into a sqlite database, normalisation isn't the first thing you do.

Re: What if OpenDocument used SQLite? (2014)

#217
post #154
post #141

Earlier quoted context omitted.

But other databases cannot access sqlite databases, because the file format is internal...

SQL file format is very well documented. In some universities it is an assignment to directly read and write sqllite files from disk and understand the paged and blocks structure. You don’t need sql for any of it. https://www.sqlite.org/fileformat.html

> In some universities it is an assignment to directly read and write sqllite files from disk and understand the paged and blocks structure.

do you have any links?

Re: What if OpenDocument used SQLite? (2014)

#218
post #82
post #28

It's somewhat off topic I know, but is there something like sqlite but tailored for hierachical data? Like a xml document store rather than for relational data like sqlite is.

There’s ASN.1 for hierarchical data with a schema. It doesn’t provide a query language though.

ASN.1 in itself is a schema syntax. That schema can be serialized into various related forms, but all of them are more or less a transport formats that cannot be reasonably used for random access.

There are some more or less general hierarchical formats with support for random access, but most of them are tightly related with particular technology stack (ie. MS's COM Compound Document) or with particular usage area (there is HDF5 for scientific data and many multimedia containers are in fact a hierarchical databases, with both the various IFF variants and EBML being explicitly designed as reusable formats for arbitrary data). And then there are formats that implicitly contain some kind of hierarchical container mechanism (PDF, TIFF, DICOM, FPS game map files…).

Re: What if OpenDocument used SQLite? (2014)

#219
Implementing versioning in the file format conflicts with git, because each document is essentially its own little source control system. This can be surprising to users who copy the file and don’t realize that they’ve effectively copied the entire repo. Copying a file will sometimes include drafts they didn’t want to share. It can mean you lose control over when things are committed, and so you don’t end up with a useful history.

If you then check the file into git, you are storing one source control system into another one, and older versions appear in two different histories. To be git friendly, you don’t want to save anything other than the current version, and then let git do its thing.

Possibly the answer is “don’t use git, we have it covered,” but then the app developer should realize that they are implementing something like a source control system. How do people share drafts, review them, and merge changes? How do you publish a release that only includes the version you wanted to release?

And it does seem relevant that the developer of Sqlite actually did implement their own source control system [1]. Maybe they could have warned people about what they’re getting themselves into if they go down this route?

I wonder how terrible it would be to either use a git repo as your file format, or to build in git compatibility into your app somehow so you could push and pull?

[1] https://en.m.wikipedia.org/wiki/Fossil_(software)

Post reply on HN