35 ms·
The database I wish I had
- sharabara 6y agoUpvote for Syncable & Embeddable. It will take a massive amount of time to build from ground up, so I wonder if it's sensible for you to build SQL on top of RocksDB like CockroachDB did: https://www.cockroachlabs.com/blog/cockroachdb-on-rocksd/ https://www.cockroachlabs.com/blog/cockroachdb-on-rocksd/
- l0b0 6y agoEspecially an immutable database (like Git's index) sounds like a very powerful concept. No more need for modification dates (they would be in the change record) and no need at all for separate log tables and all that guff. Every CRUD system ends up with some sort of audit log tacked on, costing heaps in terms of both maintenance, storage and extra processing for every change. In addition I would want there to be a command analogous to `vacuum` to truncate this history while the database is online, similar to Git's rebase or filter-branch.
- dgrin91 6y ago> An embedded, immutable, syncable relational database. Sounds like he wants a blockchain? A blockchain probably isn't really what OP wants. But funnily enough it does meet all those criteria. > what I’m after is a database to be embedded on client-side applications itself, be it desktop, browser, mobile, etc. Thats how most Blockchain clients work - on the client side, with APIs (usually RPCs) to chat with other programs > Being immutable means that only new information is added, no in-place update ever happens, and nothing is ever deleted. Immutability is exactly what blockchains were designed for. > Syncable Since blockchains are decentralized by nature, this also comes out of the box. Of course if you choose a blockchain you have to deal with a host of other issues... performance, no SQL (in most clients), harder to debug, etc. But still a fun thought experiment
- haggy 6y agoHow is blockchain relational?
- xvolter 6y agoI do not think it is. Blockchains are meant as a data store. Archival, verifiable. But not easily searchable. There is no design on blockchain for advanced query languages/logic. It seems like the OP is going after something like blockchain that adds querying. But I don't think blockchain syncing is designed well enough for client-side use, and the OP seems to want to use this database client-side in JavaScript. I think it would be possible to implement blockchain syncing with WebRTC, but WebRTC has some security risks for users (IP leakage mostly) so I am not sure I would start off with that as a primary communication channel.
- tdonovic 6y agoHyperledger fabric gets around this by storing a copy of the data up to the last block in some other db, like couchDB. That way, you get (supposedly) the best of both worlds
- dgrin91 6y agoMost blockchain clients have a DB with a cached version of the chain. This is typically done with a typical, off the shelf DB. For example Bitcoin Core uses LevelDB, but other implementations use SQL lite. As I said at the end, blockchain isn't really what OP wants. It meets his requirements mostly via technicalities.
- obi1kenobi 6y agoI have to question the "relational" part. SQL is an absolutely massive language, to the point where "we support SQL" is almost an empty statement because there's no single SQL to support. While revamping the database, consider a smaller query language. I built a GraphQL-based database query language in my GraphQL compiler project[1], and it's been a huge success at my company so far[2][3]. Here's a demo of cross-database querying with it, if you're curious [4]. [1]: https://github.com/kensho-technologies/graphql-compiler https://github.com/kensho-technologies/graphql-compiler [2]: https://blog.kensho.com/compiled-graphql-as-a-database-query-language-72e106844282 https://blog.kensho.com/compiled-graphql-as-a-database-query... [3]: https://blog.kensho.com/database-agnostic-querying-is-unavoidable-at-scale-18895f6df2f0 https://blog.kensho.com/database-agnostic-querying-is-unavoi... [4]: https://github.com/obi1kenobi/graphql-compiler-cross-db-example https://github.com/obi1kenobi/graphql-compiler-cross-db-exam...
- dragonwriter 6y ago> have to question the "relational" part. SQL is an absolutely massive language SQL is not the same thing as relational. Relational is a model, SQL is a language which (arguably, quite loosely) fits that model.
- lgas 6y agoYes and there are in fact better languages for dealing with relational data than SQL, eg. https://en.wikipedia.org/wiki/D_(data_language_specification) https://en.wikipedia.org/wiki/D_(data_language_specification...
- emilsedgh 6y agoI'm not really an expert on the field. But, have you considered that maybe SQL is massive for good reasons? The subset of SQL that covers majority of use cases is actually small and probably mostly covered by the standard. All the rest of SQL which makes it a massive beast is for all those cases where adding the logic to the database would've been the most efficient for all those who need that extra bit of efficiency.
- nanomonkey 6y agoSounds like Hypercore (DAT protocol) or Secure Scuttlebutt.
- sbazerque 6y agoYeah, except Hypercore or SSB sync'ed data types are not as flexible as the relational model. I'm building something like this, with one extra requirement: permissionless / trustless p2p operation. It works in the browser, here's the README: https://github.com/hyperhyperspace/hyperhyperspace-core https://github.com/hyperhyperspace/hyperhyperspace-core
- nanomonkey 6y agoI'm not sure what you mean by not as flexible as relational model. I'll address SSB, as I'm more familiar with it, as I've built a CRDT system on top of it in clojurescript. Each message can be linked by its content addressable hash. The engine allows for Map/Filter/Reduce queries which are not much different in capabilities from SQL queries, these can even be indexed to speed up views. The only real difference is that no schema is enforced on each message type, but it's not that difficult to enforce something like that on a higher layer when publishing entries. If you think about it, storing JSON entries is a lot more flexible than table rows. Also, the content stored need not be JSON, but EDN, transit or reference to binary blobs.
- sbazerque 6y ago> Each message can be linked by its content addressable hash. What I had in mind is, while as you well said, you can link the data in a pub in any way you need, the distribution model is fixed. The only way to change that is creating more pubs. I think the distribution model is an integral part of the data structure in a general p2p setting and needs to be customizable, within reason. Cheers!
- nanomonkey 6y agoThanks for your response, I find this stuff super interesting to watch evolve. I think I understand a bit of your concern, although note that the pubs aren't necessarily required for replication in SSB, one can use onion routing, physical devices (sneaker nets), local area connections, etc. But I agree, that there are more areas to improve, such as changing the network/capabilities keys on the fly from within a message to ratchet the distribution, making reference to content hashes within different network keys, etc. I'm curious if your work takes any of this into account? Thanks again.
- sroussey 6y agoGotta figure out what your needs are. For example, if browser and node is a requirement than you can look at RxDb which uses Pouch and either Indexeddb or various file options. If you want everything, it’s going to be big and not appropriate for web or mobile unless part of browsers or the OS.
- dsun175 6y agoAlso I see a big conflict in wanting relational data and a fast/secure replication protocol.
- mey 6y agoImmutability is an interesting property, but reality is messy. Depending on the use case you envision for the database, data that needs to be scrubbed will accidentally be added to the system. This could be an important private key, or something legally dubious. In an append only/sync system there isn't really a good way to scrub that data. (Replay the entire history, filter bad data, then delete all remotes and resync from clean copy is not good). Again depends entirely on the use case of the database you envision, but if you wish to make it general purpose it is something to consider.
- Spooky23 6y agoIt’s interesting because it reflects the reality of modern computing — for many use cases storage capacity is not a meaningful constraint. I ran pretty important systems as a DBA years ago that we’re significant but would never, ever require a meaningful constraint on growth. (Performance, different story) Sometimes looking at a problem like a database with a new set of constraints leads to interesting and novel things.
- dllthomas 6y agoSure... but needing to purge sensitive data also reflects the reality of modern computing. unsure whether to laugh or cry
- foo_barrio 6y agoI've been working on personal and professional projects where growth isn't a truly restricting constraint but is still an actual constraint. What do you mean by "meaningful"? Once I get into the 10's of terabytes there's no storage system where copying a TiB of data is "instant" or ignorable. Professionaly I work on a financial reporting system where there are around 1.5 million accounts with trading activity. Things like moving a month of data around and checksumming still take on the order of 1 hour. If the size of that monthly dataset doubled, we'd be OKAY but it it grew 10x we'd have to start restructuring things both on the software side and the hardware side. For personal work I am working with searching video frame substrings regardless of codec, resolution etc within videos in a ~50 TiB video set. Having to re-encode hundrends of GiB of video at a time is some thing that takes a huge amount of time and nothing something I can just "throw into an S3 bucket". The growth of said working set is not truly constrained but is actually constrained. I can only afford so many 8-10 TiB HDDs at a time! They also fail and have to be mirrored/backedup with rsycn at the very least which adds to the cost for me.
- jrockway 6y agoI just want a database that takes no configuration options except for a list of peers and a disk partition to write to and provides strictly serializable transactions 100% of the time (modulo partitions). I'd rather start with slow and correct, and implement hacks to improve performance once slow becomes "too slow". But instead, database engines are sold on benchmark performance, so out of the box they lose transactions they told you they committed, or read uncommitted writes, or all sorts of other crazy things. I don't want this unless I write code myself to do those things. (If I go through the API, it must be completely consistent. If I clone the drive of the database server and pick around at random disk blocks, sure, maybe I'll see some uncommitted writes.)
- implfuture 6y agoCheck out FoundationDB! It’s a distributed key value store with strictly serializable txns by default.
- jrockway 6y agoI really like FoundationDB. It still feels like that system where if it breaks you will be blamed aggressively for picking a weird thing, so I'd like to see some more success stories, I guess. But if I really care, maybe I should be the success story. The Go API is also kind of weird, and conflicts with my general thought on Go code that every I/O operation should be cancelable with a context -- they really don't subscribe to that point of view. Those are the main reasons why I don't use it... but I guess they have the fundamentals down (the "foundation" if you will), so it's probably worth powering through those nits and start using it.
- winrid 6y agoWould firebase work?
- buzzerbetrayed 6y agoFirebase (whether it be Firestore or realtime database) has almost none of the desired properties in the article. The only one it does have, as far as I can tell, is "syncable".
- winrid 6y agoYeah, just curious what they actually want to do with it that requires these properties.
- rbjorklin 6y agoIt sounds like Irmin combined with the GraphQL bindings is what he wants: https://irmin.org/ https://irmin.org/
- dwenzek 6y agoIndeed, Irmin is a library to implement data stores which can be freely cloned, updated and merged along a model similar to git. It separates the content from the actual store. So it can run as well on a file-system, on a git repository, in memory or in the browser (See for instance https://github.com/talex5/irmin-js https://github.com/talex5/irmin-js). As git, Irmin uses 3-way merge but applied to arbitrary values and not only files. As described here http://gazagnaire.org/pub/FGM15.pdf http://gazagnaire.org/pub/FGM15.pdf and generalized here https://kcsrk.info/papers/oopsla19-mrdt.pdf https://kcsrk.info/papers/oopsla19-mrdt.pdf
- rodmena 6y agoI am looking for a hero to test that 280TBs limit of SQLite.
- ultrasurf 6y agoI think what's even better than relational may be directly using OOP objects, using the system prevalence pattern. If you're willing to model your "DB updates" using event sourcing, you could fork something like Prevayler to achieve your immutability needs while being able to serve as source of truth across multiple nodes.
- eyelidlessness 6y agoOOP isn't immutable
- ultrasurf 6y agoTechnically, sure, but you can always deep-copy/serialize/etc. to make it immutable. My point is that you can achieve all the OP's needs without representing your model in SQL.
- sooheon 6y agoSQL was not one of OP's requirements.
- loopz 6y agoOOP encapsulates implementation, so you don't really know unless you break OO.
- dwohnitmok 6y agoIt's very difficult to have traditional OOP with pervasive immutability, because it almost entirely removes the idea of a stable instance of an object. There is no single instance that you call methods on or send messages to. Every method call or message processing must produce a new instance. More generally, encapsulation fails here. Immutability cannot be encapsulated behind the same interface as mutability. An immutable interface by necessity will look different from a mutable interface (at the very least methods that would normally return `void` in a mutable interface cannot ever exist in an immutable interface).
- Phil-bitplex 6y agoIt's a super interesting set of requirements - and I've been mentally trying to wrestle with an extra ones on top of that - selectively syncing data. Let's say I've got three users of my bookkeeping app. Person A and Person B are in different companies, totally separate data. Person C is a bookkeeper and wants to work with both their sets of data. It's a trivial example where you can just say "well you just keep Person A's and Person B's data separate and switch what the bookkeeper gets to see when they want to reconcile separate accounts". I don't have any good solutions for it yet, but I'm enjoying exploring them.
- spankalee 6y agoSounds very much like noms: https://github.com/attic-labs/noms https://github.com/attic-labs/noms Not sure what the status of that is since Attic Labs was acquired by Salesforce.
- tantalic 6y agoNoms has gone pretty quiet since the acquisition. Dolt is based on noms (not sure how much is has diverged) and much more active: https://github.com/liquidata-inc/dolt https://github.com/liquidata-inc/dolt
- aboodman 6y agoFYI, some of us have started working on https://replicache.dev/ https://replicache.dev/ instead, which shares some DNA with Noms. But it's not decentralized.
- alecthomas 6y agoAlas https://github.com/attic-labs/noms#status https://github.com/attic-labs/noms#status :( > Status > Nobody is working on this right now. You shouldn't rely on it unless you're willing to take over development yourself.
- 0xCMP 6y agoAlso have wanted this. Operating on data locally means it can be fast and low latency (on device, not between devices). I think the secret lies in using CRDTs to sync data in a way that allows it to be processed into another system. E.g. Postgres on a server and SQLite on a phone.
- mbalex99 6y agoYou should definitely take a look at what we’re doing at www.ditto.live
- bambam24 6y agoI have Been there, Over engineering kills startups,
- RedShift1 6y agoAh yes immutability. Until GDPR hits you :')
- dluan 6y agoWhat are the concerns with GDPR that a user-owned data approach like Scuttlebutt wouldn't cover?
- PeterisP 6y agoI'm not sure what exactly Scuttlebutt covers or does not cover, but an example real problematic situation that I have seen is like this: 1. The system among other things stores user-entered content; 2. User A has published sensitive personal data about person B (perhaps in a doxxing-like post, perhaps by making a fake profile with their name and data, perhaps including interesting images), and to make things interesting also regarding other laws in other countries, let's assume that person B is underage (which is also realistic and common, school kids do things like that to each another). 3. Person B requests that user A removes that content, and A refuses. 4. Person B escalates (the specific process does not matter much) finally resulting in you getting a legally binding request to remove that information about person B from your system/product. So the key tech requirements include both breaking immutability and full centralised control; you can do decentralised systems for e.g. performance and bandwidth reasons, but fully decentralised, user-controlled censorship-resistant technologies can't be used because then you can't implement censorship, and you need that ability.
- RedShift1 6y agoThere doesn't even have to be a person B. Under the terms of the GDPR you have the right to an erasure request, which means the party holding your data must erase your data, whatever that may be, and it must be erased from backup systems too.
- legg0myegg0 6y agoI think DuckDB checks a number of these boxes! It is embedded and written in C so compilable to WASM. It is also 10x faster than SQLite and interoperable with Apache Arrow! It might be a good place to start anyway!
- deleted 6y ago[deleted]
- chromedev 6y agoHave you ever used a flat file database? I envision the perfect database having a file system API that automatically sorts and can be edited using standard files, but stores data using like JSON or YAML. That way it can be versioned and queried using the standard file system tools, or those that implement the Unix Philosophy.
- daxfohl 6y agoI tried this for a small project once about 10 years ago, using svn as version control and putting a GUI around it. It was clunky, with no good way of doing uniqueness or foreign key constraints, and slowed way down after ~1000 records. I ended up moving to a regular database and implemented the versioning logic manually, which was pretty straightforward. At first this irked be because the final solution didn't retain the full power of a VCS. No merges, no branches, etc. But what I finally came to terms with was that it didn't need to (YAGNI): it just needed historical records and that was pretty easy. It ended up being much cleaner and faster that way.
- wccrawford 6y agoI think that you'd have to also implement indexes to make that work, just like SQL databases do. Even with SQL, I ran into plenty of cases that indexes were necessary for decent speed. Flatfiles would just amplify that. And, if you're trying to use the VCS to do merges, the indexes will constantly get messed up, so they'd have to be reindexed after every merge to be sure they were legit, and it still wouldn't ensure uniqueness... Ouch.
- sleavey 6y agoI'm building something like that as a side project and might have something to share in a week or two.
- teleforce 6y agoI'm longing and has the need for this type of database, and the time is ripe now for someone to implement it. It should be a local first and networked/distributed second, since IMHO the latter feature should be the sync problems not database problem per se. The closest to this idea is SQLite (open source and mentioned in the article) and SQL Anywhere from SAP (commercial and not mentioned in the article). But as the article pointed out most of the current solutions rely on SQL. I'd love to have the new database system to be open source and uses modern open data format for examples TileDB, Arrow and Parquet. The computation part should be language agnostic and independent of the programming languages such as JuliaDB or personally I'd prefer D programming language. Coincidentally, around seven years ago Bryan from Joyent (Joyent's presentation is mentioned as the main motivation early in the article) has blogged about this similar effort targeting POSIX systems (specifically ZFS) that eventually becomes Manta and now part of Triton a.k.a SmartDataCenter [1]. For details implementation please refer to the original paper [2]. [1]http://dtrace.org/blogs/brendan/2013/06/25/manta-unix-meets-map-reduce/ http://dtrace.org/blogs/brendan/2013/06/25/manta-unix-meets-... [2]https://queue.acm.org/detail.cfm?id=2645649 https://queue.acm.org/detail.cfm?id=2645649
- rapsey 6y agoSQL is way better at what it does then regular programming languages. Writing queries with SQL is much more succinct.
- willtim 6y agoThat depends on the programming language, for example C# with LINQ and functional programming languages are pretty good at expressing queries. SQL has no capability for abstraction and so only the simplest queries will be succint, if you want to e.g. union two similar queries then you'll have to copy and paste.
- tams 6y agoWith Common Table Expressions you can process the shared data in one set ("temporary table" is a good mental model for it), compute the unique parts in subsequent sets and use the results for the UNION in a single query.
- yashap 6y ago> I wonder if I’ll ever be able to get this done. I can’t help but be extremely pessimistic. This is an insanely challenging project. Looking at the author’s other side projects: https://euandre.org/about.html https://euandre.org/about.html I’d guess this project is about 10,000x-100,000x as challenging as the Songbooks one. And the author has no obvious experience writing DBs, that I can see? This project seems at least as ambitious as CockroachDB. Development started on CockroachDB 6.5 years ago, was founded by a group of Google alums with relevant distributed systems experience (working on GFS), and it since became well funded and has had a sizeable team working on it full time for years. This project would be almost impossible to make significant progress against without a strong, well funded team working on it for years, but the author speaks about it as a side project.
- marta_morena_25 6y agoYou are assuming that one needs to build a new database to achieve the requirements. That is unlikely. This sounds more like a glue-code project, where you combine different existing solutions, like Git, local SQL and probably a SQL server to form a whole, pre-made solution. What the author wants is implemented essentially by many many teams. Each time from scratch. All we need is someone baking this into a re-usable framework. That is STILL ambitious for a side project, but far from impossible.
- StavrosK 6y agoHe doesn't have to start from scratch, he can implement syncing/atoms/whatever else on top of SQLite.
- yashap 6y agoI don't think so. For one, he wants it to run in the browser, and SQLite doesn't run in the browser. In his "embedded" section, he makes it pretty clear that he doesn't want to build on SQLite: > SQLite is a great example of that: it is a very powerful relational database that runs almost anywhere. What I miss from it that SQLite doesn’t provide is the ability to run it on the browser > Mentat was an interesting project, but its reliance on SQLite makes it inherit most of the downsides (and benefits too) of SQLite itself. Also, I'm sceptical you could make SQLite efficient for an immutable DB, IF you want to support full SQL. A DB like Datomic has to do some pretty crazy stuff to be remotely efficient, and it doesn't even try to support full SQL - a great read on Datomic internals: https://tonsky.me/blog/unofficial-guide-to-datomic-internals https://tonsky.me/blog/unofficial-guide-to-datomic-internals Mentat, the DB he links to, is much less ambitious than this proposal, and had a couple years of work by a number of devs before eventually being shuttered/abandoned. It's about 35K lines of Rust, despite being built on top of SQLite, isn't remotely done, doesn't run in the browser, etc. Even if you did build this proposed DB on top of another DB, to make it efficient, and have all of the features discussed, I strongly suspect that it would be an absolutely massive amount of work.
- pjmlp 6y agoI am yet to see any GB/TB project that cannot be handled by traditional RDMS systems, so I don't wish for new databases other than when I have to work without either Oracle or SQL Server and wish to have their productivity tooling around.
- cafxx 6y ago> SQLite [...] assumes a POSIX filesystem that would have to be emulated. No it does not. It has a pluggable storage interface that makes no such assumption: https://www.sqlite.org/vfs.html https://www.sqlite.org/vfs.html
- scribu 6y agoIndeed: > test_onefile.c - This file implements a demonstration VFS named "fs" that shows how SQLite can be used on an embedded device that lacks a filesystem.
- earthboundkid 6y agoCame here to say that SQLite for WASM already exists. Odd to just assume it’d be impossible.
- carry_bit 6y agoAbout a couple years ago I used sql.js [1] in an internal tool to provide the user the ability to execute SQL queries against the data they had loaded. It worked just fine. [1] https://github.com/sql-js/sql.js https://github.com/sql-js/sql.js
- EuAndreh 6y agoThanks for the correction, I've amended the text. https://euandre.org/2020/08/31/the-database-i-wish-i-had.html#fn:posix-sqlite https://euandre.org/2020/08/31/the-database-i-wish-i-had.htm...
- andi999 6y agoMaybe one can learn from and avoid the biggest mistake of sql: mixed commands and date. Maybe one can separate the command from the data in the control.
- asadovsky 6y agoTake a look at Syncbase (https://vanadium.github.io/syncbase/ https://vanadium.github.io/syncbase/), it has some of these characteristics including secure p2p sync and a SQL-like query language. It's not under active development but might be a decent starting point to pick up from.
- allenu 6y agoI've built out a journal layer on top of SQLite for a flash card app I'm working on. I wanted to be able to sync data across devices but I knew that I'd always just have to handle a single-user/multi-device scenario and never multi-user/multi-device. I was able to come up with a simple CRDT style system where I just log the modifications made per device and share them out with other devices via simple files (i.e. upload to central file store and download peer journals). Each device then has to reconstruct the state of the SQLite database entries using the shared journal files. Since it assumes single user, I can safely use "last write wins" as the conflict resolution strategy. It's working reasonably well for my small use case, but there are definitely limitations that you have to be aware of. The big one is the fact that it's journal-based means the journal can grow and grow. Since I use simple files as the protocol for sharing changes, this means uploading/downloading the same content more than I'd like. If I had a stream-based server that just handled the deltas, it would be better, but my goal with this project was to avoid having to roll my own service. (I wanted users to provide their own cloud storage, say iCloud or Dropbox, and the app would just use it as a central repo, meaning no fees for maintaining the service.) There are tricks around these limitations that I can work on if I had the time (my main goal is to build the app and not a sync system). For example, I could cap the journal files to a certain size and create a new one when the limit is reached. This avoids having to upload the same contents too frequently. I could also have a strategy where I merge all journals into a central file every so often so that the state of the world is shared there instead of the journals (which can then be discarded).
- pdimitar 6y agoInteresting, thanks for sharing. I'm curious as to why you didn't use sqlite's changeset / patchset API?
- allenu 6y agoInteresting! I wasn’t aware of that feature. I actually built out my idea first as its own toy database with journals and later added SQLite as the storage mechanism. Patchset could work for this, but I’d have to play with it a bit. Off the top of my head, I’d need to redesign things to consider time in terms of sessions as opposed to granular changes. i.e. today I can just append deltas and use a time stamp to know how it fits chronologically with other changes in peers. A new peer created could sort all deltas to play back the database from scratch. I suppose with patchsets it could sort them all by start time and apply them one after the other to recreate the database. It’s an interesting problem because you can’t assume to have synced recently, so you don’t know the baseline you are starting with, but for the application I’m building, that may not matter.
- jnwatson 6y agoI already got one? My employer mostly has these requirements. We ended up writing our own query language because it is a graph DB, but all the bits are there. LMDB + a journal + a query interpreter is really all you need. We don't have off-line mirroring yet, but that's on the list. You could start with Synapse [] and rip out the bits you don't need. It is open source. [] https://github.com/vertexproject/synapse https://github.com/vertexproject/synapse
- silasdavis 6y agoReminds me of https://github.com/davebryson/bftdb https://github.com/davebryson/bftdb: sqlite replicated by Tendermint (PBFT-ish consensus)
- virtualwhys 6y ago> What I miss from it that SQLite doesn’t provide is the ability to run it on the browser. Cries in abandoned Web SQL[0] [0] https://en.m.wikipedia.org/wiki/Web_SQL_Database https://en.m.wikipedia.org/wiki/Web_SQL_Database
- CodesInChaos 6y agoIMO compiling sqlite to webassembly is a better approach than declaring a specific implementation a standard and integrating it in browsers.
- majewsky 6y agoHaving it on the browser level would have the huge advantage of the DB contents being visible to the users in devtools (not just to the developers via their custom tooling).
- osmarks 6y agoI don't think browsers have a good API it could store to, though. As far as I know there isn't really anything for storing efficiently in-place updateable/readable large binary blobs.
- CodesInChaos 6y agoWhat about IndexedDB? A basic implementation would use one document per page. An advanced integration might replace the whole sqlite storage engine with one based on IndexedDB.
- osmarks 6y agoThat could work, I forgot SQLite worked by pages. It's still probably not ideal, though.
- zubairq 6y agoYeah, I agree. At AppShare we take our server side databases and let them run in the browser. We even copy the data so that you can take a server side Sqlite database as save the Sqlite engine and all the data as a HTML file
- turingcomplet 6y agoReminds me of this https://github.com/amark/gun https://github.com/amark/gun
- thomasfromcdnjs 6y agoI think the more important question he didn't answer was "Why?" he wants a database like that.
- jeswin 6y agoDatabases we have today aren't designed for the kind of consumer applications we use today. They are designed for banks, Amazons and their smaller counterparts - where a central entity (the business or corp) needs full control over the data. The most popular consumer apps (FB, LinkedIn, blogs, photo sharing, goal trackers, slack, basecamp etc) shouldn't be centralized in this fashion. Data(bases) should be owned by users, and synced with friends and colleagues. So instead of a single centralized database, we need a million tiny little databases which are synced with peers. Tiny databases fit well into today's hardware capabilities landscape. We have plenty of fast storage, and powerful CPUs on computers and phones. It's time to stop building as if the server is the only place where queries can run efficiently. Truly serverless, that is. This also improves data security in general; there is no central place to hack. Happy to talk about this in detail. Please feel free to email me.
- beagle3 6y agoFB, LinkedIn and Slack are exceptionally happy that it is centralized; what do you mean “shouldn’t be centralized”? Who cares about what’s better for the user? He’s not the customer anyway. Sadly.
- jeswin 6y ago> Who cares about what’s better for the user? All of these apps chose technology that was available to them when they started building. So the focus could be to enable building modern usecases on decentralized data platforms. If one of them becomes the next FaceBook, personal ownership could become a baseline expectation for similar apps. Once data is owned by users, apps become a layer on top of data which can be substituted as needed. Edit: simplified.
- lozenge 6y agoDecentralization has its own issues - spam filtering, lack of moderation (people often do actually want it), anonymity.
- 6y ago
- DominikD 6y agoWith those priorities in mind I'd probably start with RocksDB and build SQL engine on top. I'm really impressed with RocksDB performance, space requirements and feature set.
- naranha 6y agoAren't relational AND syncable very difficult to combine? Foreign key references for example may not yet exist on one instance when they are synced. P/CouchDB and Git support multi master sync which is great, but they are not relational. The workaround is to detect foreign key violations in your app with indexes or a job that runs on the nodes.
- sradman 6y agoLog shipping works well for single master scenarios and these solutions can be combined with a partitioned primary key space for inserting new rows in the remote databases. A two-way embedded/server relational sync is a much more difficult problem but it has been solved before. SQL Anywhere is a commercial relational database that has exceptional synchronization capabilities for fleets of mobile devices. Its MobiLink gateway synchronizes with heterogeneous DBMS servers like Oracle. A new relational sync project should become familiar with MobiLink, in my opinion.
- jwr 6y agoI experimented with various approaches to client-side data handling and ended up realizing that I do not want a client-side database at all. I'd much rather hold data in language-native data structures (in my case, Clojure/ClojureScript). These are very powerful and there is zero impedance mismatch: after all, they are a part of the language. Yes, you do need queries, but there are not many and they might as well be coded as functions. You can do all the indexing you want, if you need to, but JavaScript in browsers is so incredibly fast these days, that even a linear search works well for most cases. Unless you are handling gigabytes of data client-side, of course. But that wouldn't make much sense. Data modification needs to go through a server API anyway, because the client environment can't be trusted, so two-way sync would be useless. I want the server to perform data model operations while verifying everything, I do not want data sync.
- dsun180 6y agoIf you do not need a database at all, of course you can just use the plain programming language.
- treis 6y ago>I'd much rather hold data in language-native data structures (in my case, Clojure/ClojureScript). These are very powerful and there is zero impedance mismatch: after all, they are a part of the language. >Yes, you do need queries, but there are not many and they might as well be coded as functions. You can do all the indexing you want, if you need to, but JavaScript in browsers is so incredibly fast these days, that even a linear search works well for most cases. That's just a bad database. It will work for small amounts of data and simple queries. But add in something complex or lots of data and it will fall over.
- mumblemumble 6y agoIn theory, if it's all in a single application's memory and using langauge-native data structures, then you have a lot of power to tailor the data model to meet your application's needs. Barring concerns like object overhead (which I realize is a major consideration in languages like JavaScript and Clojure), you should be able to come up with something that is more efficient than a general-purpose solution like a database without too much trouble. It's really just a special case of the Chuck Moore style, "I coded my own $thing in 1/10 the code and 10x the performance of the popular off-the-shelf option, in a week. NBD, it's easy if you simply choose not to implement any of the features you don't need." thing. Where DBMSes truly shine is working efficiently with data that you can't or don't want to keep in memory all at once, or for which lots of different clients need concurrent access. The first of those (but hopefully not the third) are absolutely considerations for certain kinds of browser apps, but maybe not something the parent was worrying about.
- v3gas 6y agoLove this! Rooting for you!
- hden 6y agoDatahike is an immutable Datalog database (like Datomic) powered by the hitchhiker-tree. As of v0.6.0 it use hitchhiker-tree synchronization for replication. https://github.com/replikativ/datahike https://github.com/replikativ/datahike
- knubie 6y agoTo clarify: it is planned to use hitchhiker tree synchronization in v0.6.0. The latest release as of now is v0.3.1.
- miki123211 6y agoI believe decentralization is a cool concept from an engineering perspective, but it creates more problems than it solves. The current model of big, centralized services is kinda like democracy. Bad in a lot of ways, but everything else has even bigger problems, so that's what we're stuck with. First, it's very hard for end users to actually connect and discover eachother. NATs are everywhere, so direct connections are often not possible, and introducing a central server defeats the point. Most non-techies spend a majority of their time on mobile, so having connections in the background is also not an option. Everyone having their own servers is not realistic either. It has been proven time and time again that, if people can choose between paying or getting something for free, they will choose the latter. Whether the ads are personalized or not (what some people call tracking) doesn't matter that much. Monetization is hard with decentralized services, and money is very often required to make something with good enough UX for most people. If you don't collect a lot of data, you make ad fraud easier, so ads are not an option. People don't like to pay (see above) and payments are hard to enforce if you're not managing the service, so charging is not an option either. Making decentralized services is much harder than making centralized ones. It's easier to pretend everything in the world happens in order and accept events one by one, than to deal with the messy reality of thousands of devices doing thousands of things at once, without a coordinating entity. Imagine if one user kicks everyone out from a group, while getting kicked out himself in the meantime in other parts of the network. What to do when he goes back? Who should decide? Timestamps can't be trusted either, as they can be faked. Now you're having consensus problems, dealing with byzantine fault tolerance and inventing a blockchain. A central, trusted server is easier to write and less prone to security exploits. Storing everything on your own device isn't great either. If you have 100 friends on Facebook, and each of them has 1000 photos, you don't have enough space to store them all. Not storing them isn't an option either, as you might actually want some of them at some point. Asking the original poster doesn't work, as he might not currently be in the app, so disconnected from the network. With something like a decentralized Amazon, you need search, and good, privacy-friendly, decentralized search is somewhere between hard and impossible. If you can't have captchas, rate limits and a lot of data about your users, it's hard to prevent spam, spreading fake news, attacks, catfishing and similar behavior. Restricting your network to friends works, as long as you accept the fact that no stranger (i.e. at your new place of work) can ever find or contact you. Even if you manage to overcome all those problems, there's still a pretty high risk that someone might do an embrace, extend, extinguish on your network with their proprietary app, kind of like Gmail is doing with email. I want decentralization to work and Facebook to be gone just like everyone else, but, as sad as that is, it never will.
- andriosr 6y agoI think it's crazy that database updates are still acceptable in the design of systems and databases. Updates are deletes in practice, you lose what was there before. Getting to know how Git and blockchains in general works will help in your journey. I used these concepts in the design of an immutable ledger system, the result was nice: https://decimals.substack.com/p/things-i-wish-i-knew-before-building https://decimals.substack.com/p/things-i-wish-i-knew-before-...
- dan-robertson 6y agoGDPR requires you to delete the information you have about people under some common circumstances, if they ask you to.
- AriaMinaei 6y ago> GDPR requires you to delete the information you have about people... And so does common sense.
- andriosr 6y agoSure. Immutable doesn't mean you can't delete things: > True. And what makes it easy is it's immutability. When you change history in Git, you rewrite it (rebase). But re-writing is only possible if you know every bit of the journey up to now. When you have actual updates, history is lost. https://news.ycombinator.com/reply?id=24340659&goto=threads%3Fid%3Dandriosr%2324340659 https://news.ycombinator.com/reply?id=24340659&goto=threads%...
- Someone1234 6y agoUpdates are a cost compromise. Each record is stored in 2 * [# of nodes] * 3 + [backups] places. In our case that's 15 places before we talk actual backups (online, offline, and cold storage). I'm actually a huge fan of immutable records conceptually, but I am unable to make a business case for it outside the most vital tables, that need amazing audit histories. The costs are just too high, and a lot of data not valuable enough. I'll acknowledge that if engineering time was lower it would be an easier sell, but in large databases you're still talking about at least a quadrupling of space through every layer: What's the dollars and cents argument for that?
- xwdv 6y agoI just want a database that implements a soft delete function natively.
- munhitsu 6y agoSolution should be a generic CRDT implementation with concepts of change log with unique identifiers for each participant and operation. But we also need a filesystem/operating system support for merging. As otherwise you will need to have a unique file for every operation to cope with merging. Or you have app specific merging and no data interoperability between apps. My "small" wish would be to have a local but replicated data format for a text file. So I can edit it in any editor while still retain the history and allow for collaboration from multiple devices. I'd love for it to be shared between devices using dropbox and iCloud depending of the user.
- juancampa 6y agoSled might be a useful library to build your DB on: https://github.com/spacejam/sled https://github.com/spacejam/sled
- PaulHoule 6y agoWhat you need is a "database construction kit".
- arxpoetica 6y agoThere's some cross over (not 100%) with an idea I've felt is needed in the data marketplace. See links: [1] https://github.com/datasynq/synq https://github.com/datasynq/synq [2] https://arxpoetica.com/articles/2020/07/20/why-data-needs-a-standard https://arxpoetica.com/articles/2020/07/20/why-data-needs-a-...
- brynb 6y agoThought I'd share a project I've been working on over the past year that meets at least a subset of the criteria from the article: https://github.com/brynbellomy/redwood https://github.com/brynbellomy/redwood Redwood is a decentralized database providing a data model that's much like a Redux state tree. One of the fundamental design goals was to better harmonize how data is handled on frontend and backend layers. It's also: - syncable/offline-capable, thanks to a CRDT system - able to serve as a standalone Git backend - embeddable into Go applications - immutable, in a blockchain-y sense, due to its append-only ledger There are some demos in the Github repo: - A real-time collaborative text editor - A chat application - Git integration - A video streaming application (still improving performance here, but it's functional) It's pretty alpha still, but feedback and contributions from anyone interested would be very welcome.
- Shelnutt2 6y agoDisclaimer: I'm a member of the TileDB team. > embedded, immutable, syncable relational database. TileDB Embedded (https://github.com/TileDB-Inc/TileDB https://github.com/TileDB-Inc/TileDB) checks all four of these boxes. It is a universal storage engine based on dense and sparse multi-dimensional arrays. I explain each point below. > embedded TileDB Embedded [1] is an open source (MIT licensed) embeddable C++ library which exposes C and C++ APIs. We also built APIs for Python, R, C++, Java and Go, and integrations into MariaDB, PrestoDB, Spark, GDAL, PDAL and more. Via MariaDB we even have embeddable SQL[2]. TileDB abstracts the storage backends behind an extendible VFS class, and currently supports S3, GCS, Azure, HDFS, and local disk. > immutable TileDB is designed around immutable objects. Every write creates a new "fragment" using a MVCC model[3]. No file is ever updated in place. TileDB is designed to naturally handle the eventual consistency and restraints of cloud object stores. This allows for features like multi-reader/multi-writer support, time traveling, and update support all within the storage engine without any external orchestration. > syncable TileDB's MVCC approach to handling the eventual consistency of cloud object stores, yields directly into its sync-ability. Every write operation in TileDB creates a new "fragment" [3]. A fragment is an immutable folder (or prefix on object stores) that contains all the data from a single write session. Fragments are created with a timestamp and a UUID to ensure uniqueness. The fragment is ignored until a special `.ok` file is available in listing (each write is atomic). Incomplete fragments (without the .ok file) are gracefully ignored. This means that every fragment is self-contained and syncable. The only requirement is that the special `.ok` file must show up only after the complete fragment folder is synced. With cloud object stores this is not a problem with the read-after-write consistency guarantees. For other systems the synchronization can be managed to handle this behavior. > relational database Tables can be easily modeled as multi-dimensional sparse arrays[4]. Through TileDB's integrations with MariaDB and PrestoDB (and Spark), you gain a full SQL interface, while being able to query the data directly via the language APIs without using SQL. For more robust features, such as foreign key enforcement, it is easy to use embeddable MariaDB to achieve this, while we work to push such features into the storage engine itself. We are always seeking feedback on which features are most used and requested to pushdown common operations to the storage engine. [1] https://tiledb.com/embedded https://tiledb.com/embedded [2] https://docs.tiledb.com/main/api-usage/embedded-sql https://docs.tiledb.com/main/api-usage/embedded-sql [3] https://docs.tiledb.com/main/basic-concepts/physical-storage https://docs.tiledb.com/main/basic-concepts/physical-storage [4] https://docs.tiledb.com/main/handling-dataframes https://docs.tiledb.com/main/handling-dataframes
- bionhoward 6y agoI totally agree and love this list, but also wish for graph queries like OpenCypher. The graph community really needs something like that because right now it’s all centralized, expensive and proprietary, or tied to the JVM. If SQL standards evolved to include a MATCH statement and ASCII art for traversals, it would make JOINS so much easier
- afinlayson 6y agoI've always wanted a git based database.
- mikealrogersHN 6y agoI have some good news for you :) Hi, I’m Mikeal, I created PouchDB. After a year or so I handed that project off to some great maintainers that made it much better as I had grown a little skeptical of the replication model and wanted to pursue some alternatives. It’s been about 10 years, much longer than I thought it would take, but I have a young project that finally realizes the ideas I had back then. Sometime after PouchDB was created I realized that it just wasn’t going to work to replicate a whole database to every client. In fact, even a view of the database wasn’t going to work, because the developer isn’t in a position to really understand the replication profile of every user on all of their devices, you need a model that has partial, or more accurately “selective” replication based on what the application accesses in real time. I became convinced that the right primitives were already present in git: merkle trees. Unfortunately, git did a very poor job of surfacing those primitives for general use and I wasn’t having much luck finding the right approach myself. Shortly after joining Protocol Labs I realized they had already figured this out in a project called IPLD. Not long after that, I started leading the IPLD project/team and then putting together my ideal database whenever I found a free moment. It’s very young, lots of missing features, still working on some better data-structures for indexing, but it is very much a database that replicates the way git does and approaches indexing over a primary store the way CouchDB does, but there’s a lot more too. With these primitives we can easily nest databases inside of other databases (and create unified indexes over them) and we can easily extend the data types in the database to user provided types. Using some of these features it already supports streams of binary data, databases in databases, and linking between pieces of data. Let me know what you think, there’s still plenty of work to do, but it has 100% code coverage, so it does what it says it does :) https://github.com/mikeal/dagdb https://github.com/mikeal/dagdb
- garfieldnate 6y agoYes please! I am all for anything that helps users own their own data. See also Solid (https://solid.mit.edu/ https://solid.mit.edu/) and "local-first software"/CRDTs (https://www.inkandswitch.com/local-first.html https://www.inkandswitch.com/local-first.html).