为具有以下元素的招聘网站建模数据的最佳方法是什么:
- 两种类型的用户帐户:
JobSeekers
和Employers
- 雇主可以创建
JobPost
实体。 - 每个
JobSeeker
可以创建一个Resume
实体,以及许多JobApplication
实体。-
JobSeekers
可以创建一个JobApplication
与JobPost
相关的实体实体。- 一个
JobPost
实体可能会收到许多JobApplication
实体。 - 求职者只能创建一个
JobApplication
实体每JobPost
实体。
- 一个
- 一个
Resume
包含Education
的一个或多个实例,Experience
,使用ndb.StructuredProperty(repeated = True)
。- 每个
Education
包含以下ndb.StringProperty
字段:institution
,certification
,area_of_study
- 虽然每个
Experience
包含:workplace
,job_title
.
- 每个
-
最佳答案
这是满足您要求的骨架模型:
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)
注释:
<Employer
和JobSeeker
具有内置的UserProperty
来识别并允许他们登录。Resume
使用JsonProperty
进行教育
和经验
,以允许将来有更多领域。您可以将 Python 字典分配给该字段,例如resume.education = {'institution': 'name', 'certification': 'certificate', 'area_of_study': 'major', 'year_graduated': 2013, ...}
(我个人发现 StructuredProperty 弊大于利,我现在避免使用它。)可以使用检查
JobApplication 的
现有应用程序的表。apply()
方法将JobSeeker
限制为只有一个JobApplication
关于google-app-engine - NDB 数据存储 : Data Modeling for a Job website,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20251196/