Search code examples
linkercouchdbrelationshipdocuments

how to relate documents in couchdb.when i have two differnet documents


I am new to couchdb.Now I am working on a couchdb project in my university.My project is football schema,where I have to prepare documents for players and clubs.I have already created individual documents for players and clubs in couchdb.but I dont know how to relate the players documents to the clubs documents.I mean which player belongs to which club...


Solution

  • You can store a list of doc IDs of players in each club document and/or the doc ID of the club of the player in each player document.

    Then you can use views and lists to find all players in a team for instance.

    Note that it is your responsibility to keep the database consistent (that is to remove the doc ID of a player from its club when you remove the player from the DB for instance).