Sei sulla pagina 1di 11

Replace MySQL database with Mongo

DB in Entity Layer
Contents
Contents
1. Objective
2. List of API available in Entity Layer
3. Entity Layer Mongo Persistence with multi tenancy[POC]
4. Strategies
5. Action Items

1. Objective
To replace MySQL database with Mongo DB in Entity Layer

2. List of API available in Entity Layer


1. Bulk candidate/requisition create or update or partially update [POC]
2. Delete Candidate/Requisition
3. Get Candidate/Requisition
4. Tag Candidate [Complex Query-- POC]
5. UnTag Candidate [Complex Query-- POC]
6. Richness Index Calculation [Complex Query-POC]
Note: Complex Query with joins to be realised in Mongo (Possible with version 3.2) - [POCPerformance MySQL/Mongo DB]
Note: Partial Updates to be realised-[POC- Performance MySQL/Mongo DB]

3. Entity Layer Mongo Persistence with multi tenancy[POC]


Each tenant has its own database so we need to support multi-tenancy in Mongo DB.
It is feasible in Mongo DB, there are two approaches to achieve Multi-Tenancy in Mondo DB
1. Multi-tenancy on the database level: One way to separate data for multiple
clients is to have individual databases per tenant.
2. Multi-tenancy on the collection level: Another option is to have tenant specific
collections, e.g. through tenant pre- or postfixes. [TenantName_Collection]
http://stackoverflow.com/questions/16325606/making-spring-data-mongodb-multi-tenant

4. Strategies

Suppose if

5. Action Items
In some scenario, we are joining multiple tables in my SQL database so we need to
check how we can do it in Mongo DB.

6. Performance Testing MySQL/Mongo DB[Analysis-POC]

Get 25 candidates (full set data) from MYSQL /Mongo DB by display id


Create 25 candidates (full set data) in MYSQL/Mongo DB
Update 25 candidates (full set data) in MYSQL/Mongo DB

7. DB Collection [Mongo DB Data Models]

CANDIDATE/REQUISITION [Data Model-Embedded Data Models].


REQUISITIONCANDIDATEMAPPINGBEAN [Normalized Data Models].

https://docs.mongodb.com/manual/core/data-model-design/

8. MYSQL/Mongo DB

SQL Terms/Concepts

MongoDB Terms/Concepts

database

database

table

collection

SQL Terms/Concepts

MongoDB Terms/Concepts

row

document or BSON document

column

field

index

index

table joins

embedded documents and linking

primary key

primary key

Specify any unique column or column

In MongoDB, the primary key is automatically set

combination as primary key.

to the _id field.

aggregation pipeline
aggregation (e.g. group by)
See the SQL to Aggregation Mapping Chart.

9. Java Persistence Frameworks for Mongo DB [Morphia/Spring Data]


http://www.slideshare.net/mongodb/java-persistence-frameworks-for-mongodb
http://www.fisharefriends.us/wordpress/2012/09/26/morphia-vs-spring-data-mongodb/

10 Sample JSON Candidate/Requisition


Candidate Json Structure:
{
"id": "string",
"displayId": "string",
"title": "string",
"firstName": "string",
"middleName": "string",
"lastName": "string",
"genderDisplay": "string",
"genderCode": "string",
"currentRole": "string",
"currentDomain": "string",
"dateOfBirth": "2016-05-25T06:34:34.939Z",
"noticePeriodDays": 0,
"totalExperienceMnth": 0,
"experienceInCurrentRoleMnth": 0,
"experienceInCurrentDomainMnth": 0,
"currentCtc": 0,
"currentCtcCurrencyName": "string",
"currentCtcCurrencyCode": "string",
"expectedCtc": 0,
"expectedCtcCurrencyName": "string",
"expectedCtcCurrencyCode": "string",
"status": "string",
"statusCode": "string",
"primaryEmailId": "string",
"primaryEmailIdType": "string",
"secondaryEmailId": "string",
"secondaryEmailIdType": "string",
"primaryContactNumberCountryCode": "string",
"primaryContactNumber": "string",
"primaryContactNumberType": "string",
"secondaryContactNumberCountryCode": "string",

"secondaryContactNumber": "string",
"secondaryContactNumberType": "string",
"locationId": "string",
"locationName": "string",
"locationType": "string",
"prefLocation1Id": "string",
"prefLocation1Name": "string",
"prefLocation1Type": "string",
"prefLocation2Id": "string",
"prefLocation2Name": "string",
"prefLocation2Type": "string",
"prefLocation3Id": "string",
"prefLocation3Name": "string",
"prefLocation3Type": "string",
"clientCreatedOn": "2016-05-25T06:34:34.941Z",
"clientUpdatedOn": "2016-05-25T06:34:34.941Z",
"sourceName": "string",
"sourceNameId": "string",
"sourceType": "string",
"sourceTypeId": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.941Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.941Z",
"flowId": "string",
"duplicate": "string",
"candidateUrl": "string",
"requisitionIds": ["string"],
"entityAddressBean": [{
"id": "string",
"entityType": 0,
"entityId": "string",
"addressType": "string",
"line1": "string",
"line2": "string",
"line3": "string",
"city": "string",
"state": "string",
"country": "string",
"pincode": "string",
"flowId": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.941Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.941Z"
}],
"candidateEducationMapBean": [{
"id": "string",
"candidateId": "string",
"instituteId": "string",

"instituteName": "string",
"instituteAddressId": "string",
"degreeId": "string",
"degreeName": "string",
"major": "string",
"enrolledDate": "2016-05-25T06:34:34.941Z",
"passoutDate": "2016-05-25T06:34:34.941Z",
"gradeTypeId": "string",
"gradeTypeName": "string",
"gradeMaxValue": "string",
"isHighestDegree": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.941Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.941Z",
"flowId": "string"
}],
"candidateEmployerMapBean": [{
"id": "string",
"candidateId": "string",
"employerName": "string",
"employerId": "string",
"employmentTypeId": "string",
"employmentTypeName": "string",
"employerAddressId": "string",
"designationId": "string",
"designationName": "string",
"startDate": "2016-05-25T06:34:34.941Z",
"endDate": "2016-05-25T06:34:34.941Z",
"isCurrentEmployer": "string",
"currentCtc": 0,
"currentFixedSalary": 0,
"currentVariableSalary": 0,
"currentCtcCurrency": "string",
"currentCtcCurrencyCode": "string",
"employerIndexStart": 0,
"employerIndexEnd": 0,
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.941Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.941Z",
"flowId": "string"
}],
"candidateJobFamilyMapBean": [{
"id": "string",
"candidateId": "string",
"jobFamily": "string",
"jobFamilyId": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.942Z",

"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.942Z",
"flowId": "string"
}],
"candidateSkillMapBean": [{
"id": "string",
"candidateId": "string",
"skill": "string",
"skillExprncMnth": 0,
"skillPrfcncy": 0,
"skillStrength": 0,
"skillOccurrence": "string",
"skillIndex": "string",
"skillRecencyGap": 0,
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.942Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.942Z",
"flowId": "string"
}],
"candidateProjectMapBean": [{
"id": "string",
"candidateId": "string",
"projectName": "string",
"projectType": "string",
"clientName": "string",
"employerName": "string",
"startDate": "2016-05-25T06:34:34.942Z",
"endDate": "2016-05-25T06:34:34.942Z",
"description": "string",
"roleId": "string",
"roleName": "string",
"projectIndexStart": 0,
"projectIndexEnd": 0,
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.942Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.943Z",
"flowId": "string"
}],
"requisitionCandidateMappingBean": [{
"id": "string",
"requisitionId": "string",
"candidateId": "string",
"candidateDisplayId": "string",
"requisitionDisplayId": "string",
"isCurrent": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.943Z",
"updatedBy": "string",

"updatedOn": "2016-05-25T06:34:34.943Z",
"flowId": "string",
"richnnessIndex": 0
}]
}
"requisitionCandidateMappingBean": [{
"id": "string",
"requisitionId": "string",
"candidateId": "string",
"candidateDisplayId": "string",
"requisitionDisplayId": "string",
"isCurrent": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:34:34.943Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:34:34.943Z",
"flowId": "string",
"richnnessIndex": 0
}]
requisitionCandidateMappingBean is kept outside , since this collection holds mapping of
candidates and requisitions and it requires frequent access while tagging and untagging.
Requisition Json Structure:
{
"id": "string",
"displayId": "string",
"jobTitle": "string",
"exprncFromMnth": 0,
"exprncToMnth": 0,
"statusDisplay": "string",
"statusCode": "string",
"totalOpenPositions": 0,
"jobDescriptionUrl": "string",
"crntOpenPositions": 0,
"openDate": "2016-05-25T06:39:59.300Z",
"closeDate": "2016-05-25T06:39:59.300Z",
"minComp": 0,
"maxComp": 0,
"currencyCode": "string",
"jobLevelId": "string",
"jobLevel": "string",
"businessUnitId": "string",
"businessUnit": "string",
"clientCreatedOn": "2016-05-25T06:39:59.300Z",
"clientUpdatedOn": "2016-05-25T06:39:59.300Z",

"createdBy": "string",
"createdOn": "2016-05-25T06:39:59.300Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:39:59.300Z",
"flowId": "string",
"duplicate": "string",
"criticality": 0,
"reqSourceMapBean": [{
"id": "string",
"reqId": "string",
"sourceName": "string",
"sourceNameId": "string",
"sourceType": "string",
"sourceTypeId": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:39:59.300Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:39:59.300Z",
"flowId": "string"
}],
"reqSkillMapBean": [{
"id": "string",
"reqId": "string",
"skillCategory": "string",
"skill": "string",
"skillExprncFromMnth": 0,
"skillExprncToMnth": 0,
"skillPrfcncyFrom": 0,
"skillPrfcncyTo": 0,
"skillOccurrence": "string",
"skillIndex": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:39:59.300Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:39:59.300Z",
"flowId": "string"
}],
"reqLocationMapBean": [{
"id": "string",
"reqId": "string",
"locationId": "string",
"locationName": "string",
"locationType": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:39:59.301Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:39:59.301Z",
"flowId": "string"
}],
"reqJobFamilyMapBean": [{

"id": "string",
"reqId": "string",
"jobFamilyId": "string",
"jobFamily": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:39:59.301Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:39:59.301Z",
"flowId": "string"
}],
"reqUserMapBean": [{
"id": "string",
"userId": "string",
"emailId": "string",
"reqId": "string",
"createdBy": "string",
"createdOn": "2016-05-25T06:39:59.301Z",
"updatedBy": "string",
"updatedOn": "2016-05-25T06:39:59.301Z",
"flowId": "string"
}],
"screenSelect": 0,
"screenReject": 0,
"totalCount": 0,
"businessSelect": 0,
"businessReject": 0,
"interviewedCandidates": 0,
"offerReleasedCandidates": 0,
"hiredCandidates": 0,
"yetToJoin": 0
}

Potrebbero piacerti anche