Does a primary key make sense in
job_offers? I don't think that there
is a reason for it.
Yes . I agree that every table should have their own PK.
Should each and every table have a primary key?
I have more but for case is equal,
users can be companies or single
people
job_offers has two foreign keys, one
related to company and other to
users. Is there a problem with this?
Does there exist another way to
accomplish the same task?
The system have two types of users:
normal user (person) and company user.
The job_offers is a table that save
job offers from a company. If a
company user want to post a job , a
record will be inserted to the
job_offers table . Then once the
normal user get this job offer , the
job_offers.company_user_id_user will
be assigned to this normal user 's
userid.
But from your ER diagram , Company.users_id_user
is the PK , which cannot be null , and this PK is used in the job_offers.company_users_id_user
as a FK. So job_offers.company_users_id_user
also cannot be null .
As a result , it cannot handle the situation that a company user just post a job and before a normal user gets this job offer or no one gets this job offer eventually .In this case, job_offers.company_users_id_user
should set to null , which violates the job_offers.company_users_id_user
's not null constraint.
I will accomplish the same task using this design:
Users
=================
id_user (PK)
email
activation
password
Company
=================
id_company (PK)
activities
foundation
user_id (FK to Users)
description
job_offer
=================
id_job_offer (PK)
id_company (FK to Company)
description_offer
tags
user_offer
=================
id (PK)
user_id (FK to Users)
job_offer_id (FK to job_offer)