{"action":"created","issue":{"url":"https://api.github.com/repos/arthurhsu/rdb/issues/2","repository_url":"https://api.github.com/repos/arthurhsu/rdb","labels_url":"https://api.github.com/repos/arthurhsu/rdb/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/arthurhsu/rdb/issues/2/comments","events_url":"https://api.github.com/repos/arthurhsu/rdb/issues/2/events","html_url":"https://github.com/arthurhsu/rdb/issues/2","id":130055563,"number":2,"title":"Limitations of IndexedDB?","user":{"login":"nolanlawson","id":283842,"avatar_url":"https://avatars.githubusercontent.com/u/283842?v=3","gravatar_id":"","url":"https://api.github.com/users/nolanlawson","html_url":"https://github.com/nolanlawson","followers_url":"https://api.github.com/users/nolanlawson/followers","following_url":"https://api.github.com/users/nolanlawson/following{/other_user}","gists_url":"https://api.github.com/users/nolanlawson/gists{/gist_id}","starred_url":"https://api.github.com/users/nolanlawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nolanlawson/subscriptions","organizations_url":"https://api.github.com/users/nolanlawson/orgs","repos_url":"https://api.github.com/users/nolanlawson/repos","events_url":"https://api.github.com/users/nolanlawson/events{/privacy}","received_events_url":"https://api.github.com/users/nolanlawson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2016-01-31T00:09:25Z","updated_at":"2016-02-10T04:23:15Z","closed_at":null,"body":"Hi there, I just came across this repo due to [a tweet](https://twitter.com/jaffathecake/status/693116391252217856) from @jakearchibald. I noticed you're also the Lovefield author (hello from PouchDB :smiley:), so I'm wondering: what prompted this proposal? Clearly you have experience building a relational database on top of IndexedDB, so I'm wondering what in particular you found that IndexedDB was not capable of, and why it would require a new web API.\r\n\r\nI did see your five points against IndexedDB listed in [the current spec](http://arthurhsu.github.io/rdb/), but 3 of them seem potentially solvable in an updated IndexedDB v3 spec (schema update, quota management, and cross process). For the other 2 (memory management, indexing bottleneck), I'd be curious to know more about where exactly you hit these bottlenecks in IndexedDB, if it was limited to particular browsers, etc.\r\n\r\nPouchDB is not very relational (closest we've gotten is [relational-pouch](https://github.com/nolanlawson/relational-pouch)), but looking over the spec of RDB, I don't personally see much that couldn't be implemented in IndexedDB as-is. If I were to take a stab at it myself, I would probably do:\r\n\r\n1. one single `objectStore`\r\n2. one single index\r\n3. keys prefixed by \"store\" name, `\\u0000` as separator for lexicographic ordering (pretty easy to just disallow this character in store names)\r\n4. secondary indexes managed in a similar way, with prefixes\r\n5. relations managed in-document, with IDB transactions responsible for ensuring no orphans\r\n\r\nObviously this is a pretty brute-force approach to the problem, but my guess is that the benefits (schema migrations possible, `getAll()` can be used to fetch any number of records in one query, works in Safari and IE despite their broken implementations) would outweigh the detriments (single objectStore means IDB can't smartly allow concurrent access to unrelated \"stores\", key size will be quite large). There might be other drawbacks I haven't thought of.\r\n\r\nAnyway, I just want to make sure we've fully exhausted the possibilities with IndexedDB, before we start inventing new web storage APIs. Every time I tell someone about browser storage, I feel like I have to preface my explanation with, \"well, there was A, but it was deprecated for B, and now we have C, but it's not well-supported, and oh yeah, there's also D, E, and F...\" If I have to go all the way to Z, then nobody's going to want to listen to me anymore. :stuck_out_tongue: \r\n\r\nIndexedDB was designed to be low-level enough that you _could_ write high-level APIs like the one proposed here. If it's failed in that regard, then we really need to have an honest conversation about it."},"comment":{"url":"https://api.github.com/repos/arthurhsu/rdb/issues/comments/182190139","html_url":"https://github.com/arthurhsu/rdb/issues/2#issuecomment-182190139","issue_url":"https://api.github.com/repos/arthurhsu/rdb/issues/2","id":182190139,"user":{"login":"yathit","id":2137932,"avatar_url":"https://avatars.githubusercontent.com/u/2137932?v=3","gravatar_id":"","url":"https://api.github.com/users/yathit","html_url":"https://github.com/yathit","followers_url":"https://api.github.com/users/yathit/followers","following_url":"https://api.github.com/users/yathit/following{/other_user}","gists_url":"https://api.github.com/users/yathit/gists{/gist_id}","starred_url":"https://api.github.com/users/yathit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yathit/subscriptions","organizations_url":"https://api.github.com/users/yathit/orgs","repos_url":"https://api.github.com/users/yathit/repos","events_url":"https://api.github.com/users/yathit/events{/privacy}","received_events_url":"https://api.github.com/users/yathit/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T04:23:15Z","updated_at":"2016-02-10T04:23:15Z","body":"> Shoehorn RDB on top of IDB is fundamentally flawed.\r\n\r\nIt is not flawed. A RDB library can be built using IDB without performance and consistency problem that Lovefield have. \r\n"}}