Possible Duplicate:
Many-to-Many MongoDB Association
I have been using MySQL / SQLite for many years and have real problems understanding how to do relationships in MongoDB, especially ManyToMany relationships, I just don't know what is the best practice.
Ok, I have a project with company. employeemay work for several companies, and a company may have several employees. The connection table is called contracts.
namely:
company -< contracts >- employees
Fields.
company: id, name
contracts: length, salary, company_id, employee_id
employee: id, name
My actual final application has 20 fields for each table, but I just saved them for now.
This is where my head starts to hurt, trying to reproduce this in Mongodb.
t
var company = {name:'Company A', contracts:[????]};
, . 3 , .
, , , , ?
, , ?
, MongoDB / ?
, ?
i.e: , , 10 .
, MongoDB, SQL-, , - , , ManyToMany MongoDB.
.