CouchDB modeling for multi-user

前端 未结 3 1686
Happy的楠姐
Happy的楠姐 2021-02-09 06:03

I am already excited about document databases and especially about CouchDB\'s simplicity. But I have a hard time understanding if such databases are a viable option for multi us

相关标签:
3条回答
  • 2021-02-09 06:47

    Multi-user systems do not require relational databases, though RDBMSs are a staple technology for data storage/retrieval for a vast number of (especially CRUD) applications.

    If you want to read-up on document/object -oriented, distributed database solutions of yore, search on "Lotus Notes/Domino" (it's a mature technology/product in this area that's good background knowledge in how applications are designed in a document-based paradigm. Classically, it's really good at workflow type applications).

    On CouchDB specifically, check out:

    http://wiki.apache.org/couchdb/ (this shouldn't be a surprise)

    http://seanoc.wordpress.com/2007/10/12/more-on-couchdb/ (easy reading description overview)

    http://twit.tv/floss36 (Podcast interview all about CouchDB)

    0 讨论(0)
  • 2021-02-09 06:50

    What @micahwittman says. Just a quick addition: Temp views should never be used in a production system, they are for development only. Permanent views can do everything temp views can do and are magnitudes faster.

    0 讨论(0)
  • 2021-02-09 06:52

    There was a discussion on the mailing list awhile back that fits this question fairly well. The rule of thumb was to only store data in a document that is likely to change vs. grow. If the data is more likely to grow then you most likely want to store separate docs.

    So in the case of a multi-user system one way of implementing ACL based permissions could be to create 'permission docs' that would be a mapping of user_id to doc_id with the appropriate permission indicated.

    {
        _id: "permission_doc_1",
        type: "acl",
        user: "John",
        docid: "John's Account Info",
        read: true,
        write: true
    }
    

    And your views would be something along the lines of

    function(doc)
    {
        emit([doc.user, doc.docid], {"read": doc.read, "write": doc.write});
    }
    

    And given a docid and userid, checking for permissions would be:

    http://localhost:5984/db/_view/permissions/all?key=["John", "John's Account Info"]
    

    Obviously, this would require having some intermediary between the client and couch to make sure permissions were enforced.

    0 讨论(0)
提交回复
热议问题