E
E
entermix2015-01-24 12:30:44
MySQL
entermix, 2015-01-24 12:30:44

How to implement the correct structure of the table of employees, employers?

There is a table of users, each user can act as both an employer and an employee at the same time, which table structure is correct?
1. Use 1 table:
- jobs = id, user_id, employer_id, post
2. Use 2 tables:
- jobs = id, user_id, post
- employers = user_id, job_id
3. Another option?
You will need to display a list of employees, employers, employees of all your employers

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Kudryavtsev, 2015-01-24
@kumaxim

First you need to define the essence of the system. I see two of them for you: a person (user) and work (job).
Now, your user creates a project (project), acting as an employer. For a project, we need to remember the employer first. So while there will be a job table: id, id_user
Further, the employer appoints performers for each job. Do not shove the list of performers into the project table, then you will be tormented to process data on the performer. Create a project_performer table: id_project, id, id_user In
total, we get 3 tables:
1) System users: user - id, login, salt, password, soap, etc.
2) Job(projects): job: id, id_user, desc, etc.
3) Work performers: project_performer : id, id_project, id_user,
Now your requests
1) Display all employers. The user will be the employer if his id is in the job
table 2)Display all employees. A user will be an employee if his id is in the project_performer
table 3) Display all employees of a particular employer. select user
AND job.id = project_performer.id_project AND project_performer.id_user = user.id
I can't vouch for 100% correctness of requests

S
Sergey, 2015-01-24
Protko @Fesor

Roughly speaking, you have people and vacancies filled by these people. "employees" and "employers" display the relationship between the first and second entities.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question