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...
Asked
Active
Viewed 33 times
0
-
{"_id": "33f93ebf66e59994d5359c9e500000e0_Club-info", "_rev": "2-b83326aa860d0513fc5de6e7a9af46b8", "ClubInformation": [ {"sl no.": 1, "club name": "Eintracht Frankfurt", "location": "frankfurt", "home stadium": " Waldstadion", "Founded": "08.03.1899", "club manager": "Rainer Falkenhain"}, { "sl no.": 2, "club name": "Sport-Club Freiburg e.V.", "location": "freiburg", "home stadium": " Mage Solar Stadion", "Founded": "30.05.1904", "club manager": "Fritz Keller"}]} – Ram Jan 20 '14 at 12:01
-
{"_id": "7b66d9e760278e602fe463138d000a19_Hannover", "_rev": "4-c4a0726d298f68b9df2b5b53613254d3", "PlayerDetails": [ { "Position": "Goalkeeper", "No.": 1, "PlayerName": "Ron-Robert Zieler", "Date of birth": "12/2/1989", "Nationality": "Germany", "Goals": 0, "Yellow cards": 1, "red cards": 0 }, { "Position": "Goalkeeper", "No.": 14, "PlayerName": "Markus Miller", "Date of birth": "8/4/1982", "Nationality": "Italy", "Goals": 0, "Yellow cards": 0, "red cards": 0 }]} – Ram Jan 20 '14 at 12:08
1 Answers
0
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).

Simon
- 31,675
- 9
- 80
- 92
-
thank you so much for your answer...now I got an idea of how to relate these documents.for example, I have added the club-id to each player of the club.then how to use views to display a club and its players? – Ram Jan 21 '14 at 23:27
-
Read some examples, try to come up with the best solution you can and if you are still stuck, then post a new question explaining what you tried. Chances are you can answer this one easily by just searching a bit more ;) – Simon Jan 21 '14 at 23:32