tags:

views:

68

answers:

1

Crossposting from [email protected]

Assume we have two kind of documents in CouchDB. Person and Car:

Person:

  • _id
  • firstname
  • surname
  • position
  • salary

Car:

  • _id
  • person_id
  • reg_number
  • brand

So there is one to many relationship. One person can have many cars.

I can construct map function to get every person and his/her car next to each other. In such case key is array [person.id, 0] and [car.person_id, 1].

What I can't do, is limiting this view to owners of specific brand only, e.g. if I need salaries of owners of Ferrari.

+1  A: 

Unless you really need to have a car attached to more than one person, I'd think it'd be much easier to store the cars a person owns along with the person document as sub-objects. It would make the query much easier to write.

Joel Lucsy
You are right, but it is not real life problem :) I just want to know if such query is possible in CouchDB?
amorfis