I'm building an app that needs a model of a business. The model goes something like this:
Company: {
id (primary index)
name
description
humans: [id_human1, id_human2, id_human3],
jobs: [id_job1, id_job2, id_job3]
}
Human: {
id (primary index)
company: id
job: id
name
age
}
Job: {
id (primary index)
job_name
humans: [id_human1, id_human2, id_human3]
companies: [id_company1, id_company2, id_company3]
}
I would like to be able to do the following queries: - Get all companies that have job_id = 1. - Get all humans that work for company_id = 2. - Get all jobs where company_id = 1 or - Get all humans that have job_id = 1 and company_id = 2.
How should I model the above information in tarantool and keep relationships between the data, while keeping the queries fast?
The company/job and job/company queries would be extremely simple if you normalized the tuple sets. Instead of an array of jobs in company, add a new tuple set called Company_Job {companyID, jobID}.
Then do the same with a Company_Job_Human and build secondary indexes.