views:

88

answers:

5

I'm going to allow companies to register on my website and create job listings.

I'm currently approaching the problem by creating a Company table with Name, Logo and Password fields. Then when a person registers he can say, "I belong to X company"; at this point, I'll request the password written in by the initial registrator. If she/he enters the correct password then he is given permission to create job postings in the name of the company.

Why I'm doing things this way: If I just put everything inside of the Company table, every new user would have to create an account and I'll have redundant information, CompanyName, Logo, etc.

And if I do things without a password, anyone can post a job opening under a companies name and that's just wrong.

Care to share some input? Am I doing things wrong? How would you do it?

+5  A: 

I would do "jobs requests" like Facebook's friend requests and if the user really work in that company, the company manager just has to login and confirm it.

nandu
I'd do the same.
henasraf
The user who creates a 'company' could be the 'manager' for that company. If than another user says he belongs to that company, the manager should confirm that.
Fortega
+3  A: 

Database Normalization.

Create a separate Users and Companies table. Can one user post for multiple companies? if so, you need a many-to-many relationship (which requires a third table to keep track of the relationships). Otherwise, a one-to-many should work.

Jimmy
Just as a side-note: it could be done even with just 1 table, with all the company and users fields; the company row will have the 'company fields' filled and the users fields empty and viceversa. But this will require to self-joinig the table to itself everytime.
DaNieL
@DaNieL I think this will create redundancy, this will not be a normalized solution and cant be scalable in future
Shantanu Gupta
A: 

3 Tables

Company
Company_ID
Name
Logo

Users
User_ID
Company_ID
Username
Password

JobPosting
Job_ID
User_ID
Job_Desc

kevchadders
Wouldn't you want to add Company_ID to the JobPosting Table?
Catfish
You can get the Company_ID assocaited with each user from the Users table, and with the User_ID in the JobPosting table you should be able to join across the 3 tables to get that info
kevchadders
A: 

You should create two tables:

Company:
 - id
 - logo
 ( - name, etc )

User
 - id
 - companyId (foreign key to Company.id )
 - password
 ( - username, etc. )

This way a User is a child of a Company identified by companyId. Now, if a user logs in, you can identify what company s/he belongs to by finding the Company corresponding with the companyId. Now you have a password per user, and a company per user.

And like Jimmy says, if you need Users to be able to be part of more Company's you would get:

Company
 - id
 - logo

User
 - id
 - password

Company_User
 - companyId (foreign key to Company.id )
 - userId (foreign key to User.id )
fireeyedboy
A: 

in my opinion you should create table like

Employers:

     eid(pk)
     logo
     Username
     Password
     profile
     etc....

JobSeekers:

    jid(pk)
    Username
    Password
    etc...

JobPosts:

   id(pk)
   eid(Fk to Employers.eid)
   JobTitle
   Specifications....
jayantbramhankar