0

I am working to create POS(Point of sale) application using couchdb with angular. Since i am beginner to NoSQL world. Need guidance to how to design the system.

It should be cloud based application, where login user can create companies and each company has n locations.

In relational database sense, my database design look like this.

  • While logging to my application, username & password validated against license db. If they are valid application will connect their own company db.
  • Whenever user create new company, new database will be created, all their locations, invoices, payments are in their own db.
  • License db responsible for user accounts, payments and their plan and level of security(which screen they can access/edit).
  • The application has offline support using PouchDB. where relevant location details are downloaded to user browser, and they synced back to server DB.

Questions:

  1. Is it ok to create database for each company.
  2. If user wants offline operation, they can sync own location data only(filtered replication), if they want to access other location data, application should connect cloud DB.Is it possible?
  3. I want the same code to query/insert data in couchdb & PouchDB. Is it possible?
  4. Is couchdb map-reduce/mango query support complex reports
  5. Is Angular+Couchdb is enough, or do I need any server side framework.I don't any third-party authentication right now.
  6. How the above relational database design should be implemented in couch db

what are the other things i should think about this software design

Nest
  • 341
  • 4
  • 23

1 Answers1

0
  1. Yes. One common design for CouchDB is to have a database per user. One per company is totally reasonable.
  2. CouchDB supports filtered replication. You could setup a filtered replication for user's documents on a local database instance (PouchDB or CouchDB)
  3. PouchDB allows you to connect to CouchDB. Basically, you could have a PouchDB library that does all your business operations. You would only need to change the database adapter for the cloud or client database.
  4. Map/Reduce is pretty straight forward. It allows you to index documents and query them by their keys. You can easily change the values in your indexes and also use reduce functions. Mango queries are more flexible. A bit similar to MongoDB.
  5. You might eventually needs an application layer but that's possible to use only CouchDB.
Alexis Côté
  • 3,670
  • 2
  • 14
  • 30
  • Regarding angular to couchdb connection, where I store couchdb username & password, Is server side library was necessary. I don't think login users are in _users database. I need to custom registration/forget password and setting security for each user. – Nest Jan 26 '19 at 04:47
  • 1
    Its usually a good idea to add a microservice or something in the backend to handle authentication/registration. Otherwise, I think you can put your database public so people can register to it. Altought, I'm not aware how the "permissions" are handled. Maybe the per-user feature can help with that – Alexis Côté Jan 26 '19 at 19:14
  • In 3rd Point, Do you mean design documents are also replicated in PouchDB. But based on this question(https://stackoverflow.com/questions/39256692/pouchdb-replication-of-design-documents), we should not replicate DDocs in PouchDB. I don't want my end user can see design docs, using chrome dev tools. Instead of map-reduce, Is using mango queries solve this problem. – Nest Mar 05 '19 at 12:39
  • @Nest I don't see how my 3rd points mention the usage of design docs. – Alexis Côté Mar 05 '19 at 23:29