2
votes

What is the best way to model data for a job website which has the following elements:

  • Two types of user accounts: JobSeekers and Employers
  • Employers can create JobPost entities.
  • Each JobSeeker can create a Resume entity, and many JobApplication entities.
    • JobSeekers can create a JobApplication entity which is related to a JobPost entity.
      • A JobPost entity may receive many JobApplication entities.
      • A JobSeeker may only create one JobApplication entity per JobPost entity.
    • A Resume contains one or more instances of Education, Experience, using ndb.StructuredProperty(repeated = True).
      • Each Education contains the following ndb.StringProperty fields: institution, certification, area_of_study
      • While each Experience contains: workplace, job_title.
1

1 Answers

2
votes

Here is a skeleton model that meets your requirements:

class Employer(ndb.Model):
    user = ndb.UserProperty()

class JobPost(ndb.Model):
    employer = ndb.KeyProperty(kind=Employer)

class JobSeeker(ndb.Model):
    user = ndb.UserProperty()
    def apply(self, job_post):
        if JobApplication.query(JobApplication.job_seeker == self.key,
                                JobApplication.job_post == job_post).count(1) == 1:
            raise Exception("Already applied for this position")
        ...

class Resume(ndb.Model):
    job_seeker = ndb.KeyProperty(JobSeeker)
    education = ndb.JsonProperty()
    experience = ndb.JsonProperty()

class JobApplication(ndb.Model):
    job_seeker = ndb.KeyProperty(JobSeeker)
    job_post = ndb.KeyProperty(JobPost)

Notes:

  • Employer and JobSeeker have the built-in UserProperty to identify and allow them to login.

  • Resume uses JsonProperty for education and experience to allow for more fields in the future. You can assign a Python dictionary to this field, for example resume.education = {'institution': 'name', 'certification': 'certificate', 'area_of_study': 'major', 'year_graduated': 2013, ...} (I have personally found StructuredProperty to be more pain than gain, and I avoid it now.)

  • Limiting a JobSeeker to only one JobApplication can be done with the method apply() which checks the JobApplication table for existing applications.