Hi, You would be needing three tables at least as you are requiring a many-many relationship. If you want industries to be separate (ie, you could say computing industry) then you can include a further table of industry however for now it seems you are just looking at linking the job types so I'll explain that - if you do want separate industries then let me know and I'll update it!
Anyway, you would have the following tables: (Hope you are familiar with this notation - if not, say so!)
JobType(ID, description, etc etc...)
Person(ID,forename, surname, telephone, etc etc...)
This is the important 'link' table!
SeeksJob(fk:JobType:ID,fkerson:ID, dateCreated, etc etc...)
So... Everytime a person wants to seek a job then you create a new record in SeeksJob with the id of the person, and the id of the job they seek. I used 'id' for the primary key of jobtype and person although you 'could' say that the primary key is another field (national insurance number, job type etc... it just is easier to do it this way atm!)
The primary key in seeksjob is a composite of the foreign keys 'id' from person and jobtype. Obviously where I have put 'etc etc...' you can store any other info you may want to in there...
So, lets say you populate your database with the following job types (small atm):
Code:
1 - Web Designer
2 - Programmer
3 - Slave
and I come along saying I am looking for a job as a programmer. You then create a "person" record for me along the lines of:
Code:
INSERT INTO person VALUES('','John','Keymer','01344567890'');
I have assumed that you have used auto_increment on 'ID' so it automatically give sme an ID if I supply null to that field. Lets say it gives me ID number 1. (I am the first in the database! {This number system starts at 1, not 0, for those who may pick. }).
You then create a seeksJob record as follows:
Code:
INSERT INTO seeksJob VALUES('2','1','todaysDate');
Where '2' above is the code for programmer and '1' is my ID.
Now, if I also seek to be a web designer, you just use my existing ID (1) but job code 1, and create another record in seeksJob like so:
Code:
INSERT INTO seeksJob VALUES('1','1','todaysDate');
So a person can seek as many different job types as he likes - in the above, you can not have the person seeking the same job twice (makes logical sense really don't it, lol!) due to the primary key restrictions.
Now, lets say a manager wants to find all people looking for a job as a web designer. He just has to execute a query like this:
Code:
SELECT forename, surname, telephone FROM SeeksJob,Person WHERE SeeksJob.jobID='1';
You could even use more complex SQL to have it done by description of the job (see below), however I assume your system will deal with this side of things (how exactly things are searched for - ie, from a drop-down box, by entering manually the job type etc).
Code:
SELECT forename, surname, telephone FROM SeeksJob, Person WHERE SeeksJob.ID='(SELECT ID FROM JobType WHERE description='Web Designer' LIMIT 1)';
Without further info on what EXACTLY you are planning to do and how exactly you are planning to implement it, it's difficult to say much more however I hope this has been of some help! Feel free to ask anything you're not sure about.
-John-
Social Networking Bookmarks