Jump to content

[SOLVED] multiple references in a table?


SirDuke

Recommended Posts

Hi there. This is my 1st post in this (surprisingly good-looking) forum.

 

i am using mySQL for a project

 

i have a database to manage a company and have a table for emploees (name, salary, ...) and a table for jobs (title, cost, ...). Each emploee can work in many jobs and of course each job is done by many emploees. How do i implement this in mySQL??

 

 

I cannot add a field "emploee_id" in the jobs table cause clearly there are more than 1 emploees on the job. How can i make this dynamic? Always have space for more emploees and never unused space?

 

I am sure this a trivial matter cause it is very common, and i would love to learn the solution  ::)

Link to comment
Share on other sites

you will have a crossing table or a normalization something like

 

employee

---empid

---name

--ect....

 

job

--jobid

--jobdesc

--etc..

 

eployeeXjob

--empid

--jobid

 

Select * form employee

left join job on  eployee.empid = job.empid

left join employeeXjob on employeeXjob.empid = employee.empid

etc....

;D

Link to comment
Share on other sites

hmm.. interesting answer..

 

unfortunately i have no idea what "left join" does so i'll have to look it up :) (if there is a really good resource somewhere feel free to let me know -apart from the mysql docs)

 

Thanx for  the answer, though i might return tomorrow with more questions :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.