开发者

Advice on "schema" for some related data in MongoDB

开发者 https://www.devze.com 2023-01-15 21:30 出处:网络
I have a project I\'m working on and I want to use MongoDb. Description: The programme is a questionnaire for an entity. The entity can be college, 开发者_运维知识库faculty or department. A form is

I have a project I'm working on and I want to use MongoDb.

Description: The programme is a questionnaire for an entity. The entity can be college, 开发者_运维知识库faculty or department. A form is captured per year for any of these entities though mostly departments. Queries can be made on any of them. Where needed, the data can be aggregated and used in ranking.

Relationship: Colleges contain faculties and faculties contain department. Each of them (well departments at the moment has forms). There can be a number of form types (3 at the moment)

Problem: How do I represent this scenario in MongoDb? First is the College > Faculty > Department relationship. How do I effectively represent this?

My current thoughts: 1. Concerning the College > Faculty > Department data, I was thinking I could use a single collection and tag them according:

{name:'Department X', tags: ['department'], parent: '???'}

. The parent could be the id of thee parent element so in this case the id of the associated department. The other option was

colleges: {name: 'some college',etc,faculties: [{name: 'some faculty', etc, departments: [{...}]}].

The issue was the id I would use to identify each ,eg, department.

  1. For the forms, I'm still not sure. If I embed the data in the department records, how easy will it be to retrieve for a number of departments, say in a faculty and do some sumation on most of the fields (most are number)?

Really need some assistance here coming from a relational background. I'm using c# with CSMongo by Hugo.

Regards, Richard


Are you sure that faculties can contain department not the college contains the departments?

Also how does a form look like?

Please give me an complete example of one document with a college, 2 faculties, few dept and few forms. That way I might be able to give you some guidance.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号