localStorage vs SQLite?

2019-06-25 08:58发布

问题:

I'm building a Packaged App for Chrome. Looking into my database options, I'm curious if I understand the proper way of using these.

With SQLite, I'd create table books with the following rows _id, title, category, date, price, qty_sold.

With localStorage, I'd create table _id with key/pair such as 1, x499faj4. Then I'd create table title with key/pair x499faj4, book title. Table category, with x499faj4, fiction.

I'm not sure if that makes sense. localStorage seems easier to implement but how would I then go about sorting those things to populate a list by category, price or quantity sold for example? Does localStorage make sense in this situation and am I using it properly? Any further suggestions? thanks

回答1:

localStorage is strictly a key/value store, so any kind of aggregation, sorting, filtering will all have to be in your own application code. SQLite is just that, a pretty robust SQL based storage engine, complete with sorting, filtering, etc.

SQLite while a little more complex to setup and get started will probably be extremely more robust in the long run.