Search code examples
javamongodbdatabase-schemasaasmorphia

Recruitment Management Portal Datastore / Schema Design For MongoDB


I want to use MongoDB for creating a SAAS Recruitment Management Portal, which will address following use cases,

  1. One smart HR Manager would register their company on portal ( hence two resources found so far An HR Manager , and A Company )

  2. Company will have it's own profile page like http://myportal.com/abccompany ( same as twitter does )

  3. After registration HR Manager can invite other HR managers from her company ( business validation applied here is same as yammer , domain name based access [email protected] can invite [email protected] )

  4. After inviting all possible employees , HR Manager will start posting Jobs ( we found third resource now , A New Job Opening !! )

  5. After creating a new Job Posting we get URI for that Job , which could be published in Social media, other job portals etc..

  6. If communicated right, A Candidate would get interested in a Job Opening at Abc Company and he will make a Job application after registering a Candidate profile on our portal. ( we found two more resources now Candidate and A Job Application )

  7. Job Application is the resource where we will have most of the transactional data , this resource will keep changing fast as Job Application will traverses thru and will capture multiple phases of recruitment activities ), rest of the resources are mostly read only.

  8. Down the line, there will be a huge database of Candidates which is intended to be kept separate from other data so as to reuse them as Candidate Profile, that means Candidate data is not tied to a specific Company.

How do I model this in MongoDb ( preferably using Morphia - A java library ) to achieve following goals,

  • To get optimize queries on Job Application resource
  • To get the advantage of full text search provided by MongoDB

Solution

  • Two things which struck me as a little odd:

    Job Application is the resource where we will have most of the transactional data , this resource will keep changing fast as Job Application will traverses thru and will capture multiple phases of recruitment activities ), rest of the resources are mostly read only.

    You are aware that MongoDB doesn't support transactions in the conventional sense (spanning multiple documents)? This isn't such a big problem as data modelling is different to relational databases and you might be able to accomplish many features with a single document (which is pretty much transactional).

    To get the advantage of full text search provided by MongoDB

    MongoDB currently doesn't support full-text search - it's often requested and planned, but will take some more time: https://jira.mongodb.org/browse/SERVER-380

    However, Morphia supports regular expressions and you can manually tokenize / stem.

    While you can easily use MongoDB for this, I don't see any reasons why you couldn't go with MySQL as well.

    For modelling I'd start with a simple approach (company-user, company, job-posting, candidate, application) and only start to optimize if you are actually having performance issues. Caching should get you a long way in your scenario.